Skip to content

Instantly share code, notes, and snippets.

@lordofthedanse
Last active December 26, 2018 19:33
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 lordofthedanse/dfec4c93374033c1b1deee5e1b4a2612 to your computer and use it in GitHub Desktop.
Save lordofthedanse/dfec4c93374033c1b1deee5e1b4a2612 to your computer and use it in GitHub Desktop.
After using squasher to squash Rails migrations ...

Here are a few gotchas:

  1. If you were running spring and didn't stop it before you squashed migrations, spring might have it's database config change (it'll look for the squasher database that was created temporarily). If you want to go back to your development database, just spring stop and then setup your database (however you do that) again.
  2. You can run into rake db:migrate problems because the new squashed migration version has not been added to the schema_migrations table that tells Rails what migrations have already been run. Thus, your rake db:migrate command will be trying to create tables (via the squasher XXXX_init_schema migration) that already exist. The solution to this is to manually insert the value of your XXXX_init_schema migration into the schema_migration table:
  • psql
  • insert into schema_migrations (version) values ('99999999999999');, where the 99999999999999 value is actually the timestamp that appears in the XXXX_init_schema migration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment