cli
cli copied to clipboard
Rails like migration generation
The CLI should support rails like migration generation á la:
sequelize migration:create --name=create-products
Which generates a new migration with a corresponding scaffold:
module.exports = {
up: function(migration, DataTypes, done) {
migration.createTable(
'products',
{
// @todo implement
}
);
done();
},
down: function(migration, DataTypes, done) {
migration.dropTable('products');
done();
}
}
Oringinal sequelize bin
has this feature. :wink:
Original one just had the up/down skeleton i believe. It didn't have skeletons for createTable and similar
What @mickhansen said. Yes there is the feature of generating a skeleton. Yes you can specify the name of the migration. No you cannot generate a sensible skeleton, yet.
This issue is partially covered by #12
Having RoR/Django South like generated migrations would definitely take Sequelize to a whole new level.
+1 super keen for this
+1
While generating an initial migration along with a model using model:create
is nice, the creation syntax doesn't support associations, which then have to be manually added in both the model and in a migration (and boy, figuring out how to create FK relationships in a migration wasn't fun).
I would really rather model:create
only created simple models which I could then edit to add associations to, and migration:create
could then take the edited model (with the associations) as an argument to generate the correct initial migration file, FKs and all: ./node_modules/.bin/sequelize migration:create --model server/models/person.js
This would still fall short of autogenerated migrations for model changes (such as South and Alembic can do), but it would be a huge step up for starting a project.
+1
+1
Same here: https://github.com/sequelize/cli/issues/257