Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate initial migration from model? #157

Open
jsumners opened this issue Jul 21, 2015 · 203 comments
Open

Generate initial migration from model? #157

jsumners opened this issue Jul 21, 2015 · 203 comments

Comments

@jsumners
Copy link

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.

  1. I create my initial model, wherein I fully describe the table
  2. I then create a migration for it where I mostly just copy and paste the previously written definition
  3. 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?

@sdepold
Copy link
Member

sdepold commented Jul 21, 2015

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 notifications@github.com
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.

  1. I create my initial model, wherein I fully describe the table
  2. I then create a migration for it where I mostly just copy and paste the previously written definition
  3. 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:
#157

@jsumners
Copy link
Author

If I get a chance I'll see if I can work something up. But I'm not sure I'll have the opportunity.

@o5
Copy link

o5 commented Oct 19, 2015

+1 :)

@mwain
Copy link

mwain commented Oct 27, 2015

+1

@DenLilleMand
Copy link

+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'

@bbbeeeee
Copy link

bbbeeeee commented Dec 7, 2015

+1

1 similar comment
@agolendukhin
Copy link

+1

@amit034
Copy link

amit034 commented Jun 2, 2016

Is there any progress? or alternative?

@sdepold
Copy link
Member

sdepold commented Jun 3, 2016

no progress afaik

@zmts
Copy link

zmts commented Jun 30, 2016

+1 Will be the very popular feature. I hope this feature will be implemented

@kkleidal
Copy link

+1

9 similar comments
@suricactus
Copy link

+1

@oliv23
Copy link

oliv23 commented Oct 15, 2016

+1

@WaqqasMeraj
Copy link

+1

@juniorplenty
Copy link

+1

@atlantageek
Copy link

+1

@bradleyy1012
Copy link

+1

@jcfinnerup
Copy link

+1

@Anomnimel
Copy link

+1

@darrenchiu
Copy link

+1

@zmts
Copy link

zmts commented Jan 12, 2017

By the way, now I use https://github.com/Vincit/objection.js/
Very nice convenient ORM

@notgiorgi
Copy link

+1

Though currently I'm doing it this way: https://gist.github.com/notgiorgi/7276aae5baebb5725799ce0f5b8468f3

@SargeKhan
Copy link

SargeKhan commented Jan 25, 2017

I would like to start working on this feature. Can anyone give me pointers on where I should begin?
Thanks a lot.

@omeragich
Copy link

+1

5 similar comments
@iDVB
Copy link

iDVB commented Feb 16, 2017

+1

@willsr
Copy link

willsr commented Mar 6, 2017

+1

@roybrey
Copy link

roybrey commented Mar 29, 2017

+1

@minhnhat2807
Copy link

+1

@laynef
Copy link

laynef commented Apr 19, 2017

+1

@eugene-matvejev
Copy link

+1

@cjancsar
Copy link

cjancsar commented Jul 7, 2019

Has any work been done towards achieving this? Can anyone outline the steps that should be taken to do this?

I come from Django which does all of this for you, so it was very surprisingly to learn that such basic ORM functionality does not exist out of the box for this package (same with: #257)

Our company is starting a new long term project using Sequelize. Since this is obviously very sought after functionality based on all the +1s; and since the maintainers are absent in addressing it, if someone can point me to any initial work that has already been done on the subject we can start to add some cycles to addressing it.

From what I see, these are the best candidates for this type of functionality so far:

Instead of all the people saying +1 why don't we just do something about it?

@jsumners @sdepold have you made any progress, or do you have an outline of the steps you would take to add this feature?

If a PR was made to add this, would it be addressed or is this something best left to external packages like sequelize-auto-migrations

@jsumners
Copy link
Author

jsumners commented Jul 7, 2019

@cjancsar sorry. I never progressed past reasearching this module.

@tejaram15
Copy link

tejaram15 commented Jul 8, 2019 via email

@acharzuo
Copy link

acharzuo commented Jul 9, 2019

+1

@javiermrz
Copy link

Started using sequelizer today, seems a great ORM but just jumped into this, which I think is a feature that it should have from the beggining :(

@matiasbenedetto
Copy link

Started using sequelizer today, seems a great ORM but just jumped into this, which I think is a feature that it should have from the beggining :(

Same!

@pbirsinger
Copy link

I am literally going to abandon sequelize, never use it again, and recommend everyone else stay far away from it if this feature doesn't come very soon.

@javiermrz
Copy link

javiermrz commented Jul 26, 2019

Guys, I managed to get myself another tool working next to sequelize, and now I have the full set. I use Sequelize only as a mapper for interacting with the database, and for migrations Im using Postgrator. I really recommend you guys taking a look at it. It's really similar to Flyway (for Spring) and It applies database version control in an easy way. I find It a great combo, and I dont need the migrations features of Sequelize anymore, I even find that Postgrator is better with that than Sequelize would be.

So just create the DB with the Sequelize models, and when you are ready just dump it and use that .sql file as the first version of your database for Postgrator :)

@jy95
Copy link

jy95 commented Oct 24, 2019

No progress yet ?

@xjnotxj
Copy link

xjnotxj commented Dec 6, 2019

还没有进展吗?
+1

@fischettij
Copy link

+1

@irisEco
Copy link

irisEco commented Dec 22, 2019

That's a very bad feeling......

@OlivierCuyp
Copy link

This feature should really be implemented in the official CLI. There was a nice side project doing it but it feels a bit abandon :

https://github.com/flexxnn/sequelize-auto-migrations

Might still be a good pointer to start the implementation.

@OlivierCuyp
Copy link

OlivierCuyp commented Dec 23, 2019

@janmeier this feature request is opened since 2015. Could you let us know if there is any progress on it ?

To me, sync is most of the time not a good idea.
And migrations is the right path to go but it is painful. So auto-generate migrations from models would be really nice

@sksankarraj
Copy link

+1, hello from 2020

@yeongjet
Copy link

yeongjet commented Jan 2, 2020

Any hope in 2020?

@vietduong-agilityio
Copy link

No hope :))

@webdevbyjoss
Copy link

webdevbyjoss commented Jan 21, 2020

There is a hope now https://github.com/flexxnn/sequelize-auto-migrations

@OlivierCuyp
Copy link

OlivierCuyp commented Jan 24, 2020

@webdevbyjoss as I commented previously, sadly this project feels a bit abandoned ...

@papb
Copy link
Member

papb commented Jan 24, 2020

Hi everyone, this project is not abandoned, however I am super busy at the main repo for now; hopefully in the near future I will be able to make the super overhaul that I am planning for the Sequelize CLI. Thanks for the patience so far 😬

@OlivierCuyp
Copy link

Hi @papb, I was speaking about https://github.com/flexxnn/sequelize-auto-migrations.
But I'm really glad that you plan to take a deeper look at this issue in the near futur.

@randyzhao
Copy link

I wonder if anyone could recommend an alternative library which has this feature implemented.

@billkiddo
Copy link

Hi everyone, this project is not abandoned, however I am super busy at the main repo for now; hopefully in the near future I will be able to make the super overhaul that I am planning for the Sequelize CLI. Thanks for the patience so far 😬

define "near"

@tkssharma
Copy link

i see this is a miss from sequelize, it can be every helpful generating initial migration from defined models, here we have to copy it again in two places with sync off feature !!

hrbocutti added a commit to hrbocutti/cli that referenced this issue Apr 6, 2021
hrbocutti added a commit to hrbocutti/cli that referenced this issue Apr 6, 2021
@hrbocutti hrbocutti mentioned this issue Apr 6, 2021
@pablodsilva
Copy link

It was solved with sequelize-auto. Afte make the migration, run sequelize-auto to sync the model file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests