#157·cli

Generate initial migration from model?

Author: jsumnersCreated Jul 21, 2015Updated Oct 21, 2025

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?