Skip to main content

migrations

Migrations​

When creating an migration and its model, please keep in mind:-

  • Make sure to index the frequently searched by attributes, for example foreign_keys, emails, or uniq identifiers.
  • Make sure to associate with ID (foreign_key and primary key)
  • Make sure to think it through before define the table column.
  • Try to avoid json if the record needs to be searched down the line by json keys.

Please keep in mind​

  • If you are adding, removing and/or indexing column/table, please make sure to deactivate auto-deploy, let your migration complete and re-activate it. This is because when heroku CI deploys your code and runs the migration, second deploy is not aware of the migration changes yet, meaning schema is not updated yet, and waiting for migration to go through will update the schema so the second deploy does not try to re-migrate, resulting in exceptions like 👇
screen shot 2018-03-26 at 11 32 52 am