cli
cli copied to clipboard
Generate initial migration from model?
I'm just getting started with Sequelize and the CLI. I want my project's initial database to be bootstrapable with sequelize db:migrate
(i.e. create the database from nothing with an initial set of migrations). In that regard, it seems to me that I am duplicating a lot of code.
- I create my initial model, wherein I fully describe the table
- I then create a migration for it where I mostly just copy and paste the previously written definition
- If there are changes to be made before committing, I get to make them in multiple places
I have a simple two table test project at https://github.com/jsumners/sequelize-migration-test that shows what I'm describing.
Would it not be possible (make more sense) for sequelize migration:generate
to read the already defined model and generate the migration from that definition?
Yes. That would be a good idea and I'm planning to do that since a while already but never found the time for that :(
On Tue, Jul 21, 2015 at 11:09 PM, James Sumners [email protected] wrote:
I'm just getting started with Sequelize and the CLI. I want my project's initial database to be bootstrapable with
sequelize db:migrate
(i.e. create the database from nothing with an initial set of migrations). In that regard, it seems to me that I am duplicating a lot of code.
- I create my initial model, wherein I fully describe the table
- I then create a migration for it where I mostly just copy and paste the previously written definition
- If there are changes to be made before committing, I get to make them in multiple places I have a simple two table test project at https://github.com/jsumners/sequelize-migration-test that shows what I'm describing.
Would it not be possible (make more sense) for
sequelize migration:generate
to read the already defined model and generate the migration from that definition?Reply to this email directly or view it on GitHub: https://github.com/sequelize/cli/issues/157
If I get a chance I'll see if I can work something up. But I'm not sure I'll have the opportunity.
+1 :)
+1
+1. Well, it is just javascript, so im going to make a file that exports the javascript object, that the model in models/ and migrations/ can import. Not going to set my self up for the inevitable 'change one place, but forgot the other'
+1
+1
Is there any progress? or alternative?
no progress afaik
+1 Will be the very popular feature. I hope this feature will be implemented
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
By the way, now I use https://github.com/Vincit/objection.js/ Very nice convenient ORM
+1
Though currently I'm doing it this way: https://gist.github.com/notgiorgi/7276aae5baebb5725799ce0f5b8468f3
I would like to start working on this feature. Can anyone give me pointers on where I should begin? Thanks a lot.
+1
+1
+1
+1
+1
+1
+1