-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Option to skip Migrations contract #503
Comments
PR's welcome. Thanks for your input. |
Please see the |
A tricky way of doing this:
|
I logged in to GitHub just to support the user who said that using Migrations is a horrible idea. I came to this issue by searching google : "how to remove migrations from truffle". I don't know who engineered this but it's the worst engineering thing I have seen:
Horrible, horrible, horrible. |
I think the migration part needs more work and love, @nuliknol just hating, but he is welcome to not use truffle migrate. |
Thanks for the suggestion @masato25 that's really helpful! Here's a slightly nicer way: module.exports = {
networks: {
...
skipMigrations: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
}
}
}; in your migration scripts (e.g. 2_deploy_token.js): module.exports = async function (deployer) {
if (deployer.network === 'skipMigrations') {
return;
}
// Do the normal migration stuff:
...
}; Running tests: |
I was currently using somehting like that. Never realy imagine it as a way to skip migraitons. var privateChains = ['kaleido', 'ganache', 'remoteGanache'];
var publicChains = ['ganachet', 'ganache', 'mainnet'];
if(privateChains.includes(network)) {
// deploy private contracts
...
}
if(publicChains.includes(network)) {
// deploy public contracts
...
} |
I came up on this thread trying to avoid deploying the Migrations contract because of Ethereum's ongoing gas cost booms. Following @ccolorado outline, I've edited const Migrations = artifacts.require("Migrations");
var publicChains = ['ethereum_live', 'ethereum_live-fork'];
module.exports = function (deployer, network) {
console.log(network);
if(publicChains.includes(network)) {
return; //We don't want a Migrations contract on the mainnet, don't waste gas.
}
deployer.deploy(Migrations);
}; I really never understood why Truffle maintains that silly "Migrations" fetish architecture that is not only completely useless, but also completely arbitrarily wasteful considering gas fees. |
Any updates on this? A project with 30+ migrations make testing impossible |
I think that it will be enough for truffle test to accept the "-f" (from) and "--to" flags, as interpreted by truffle migrate. There are very good reasons to skip deployments while executing tests. Functional test or integration test will require deployments to get sure that functional and/or integration tests work as expected. Unit-test have a real need to skip deployment to be able to test in isolation (vs test output dependent on random/non-specific JS deployments that could alter the test output). Can anyone guide where to patch in code this issue? |
Hi @earizon. |
Guys, your idea with storing deployment state on-chain is just awful.
First of all, this just does not help. There are many other much better ways to store info.
Also, this works only if all is working good. If smth was broken (code, Ethereum node, network etc.) - debugging becomes a nightmare. Manual excessive logging required from developers
It is much better to have a JSON file or SQLite database with migration state, with full logging of performed actions. And store this file in the git repo.
At least, make it possible to run arbitrary migration script manually. Not just
--reset
and run all migration scripts from the scratchAlso, consider making truffle a library, not a framework. It will be much easier to write tests and migration scripts, and just run them with node.js.
The text was updated successfully, but these errors were encountered: