Skip to content

Instantly share code, notes, and snippets.

@donpinkus
Created November 8, 2019 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpinkus/6db973f48b83c9c46eb115f1f79d1c43 to your computer and use it in GitHub Desktop.
Save donpinkus/6db973f48b83c9c46eb115f1f79d1c43 to your computer and use it in GitHub Desktop.
Sequelize migration docs

Creating a model from scratch

  1. How do you create a migration for a new model? $ sequelize model:create --name User --attributes "email:string, password:string"

  2. How do you create a migration for a new model with an association? Run step 1, then add it yourself.

Updating a model

  1. How do you create a migration for an existing model? $ sequelize migration:generate --name doSomeThingsHere

  2. How do you create a migration for an existing model that adds an association?

General

  1. How do you run your migrations manually? $ sequelize db:migrate

  2. How do you run migrations automatically? ? Maybe db.sync()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment