Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip rails migrations after creating database from dump

I restored my database from the latest dump and tried to run rake tests. Unfortunately 30 migrations were pending. My first idea was to comment out each of 30 migrations code and run 'rake db:migrate' but there must be a simpler solution. I use Rails 2.3.14 and Postgresql 9.1.3.

like image 393
Piotr Brudny Avatar asked May 14 '12 09:05

Piotr Brudny


1 Answers

If you're restoring a database from a dump, the schema_migrations table should restore along with the rest of the tables.

This seems to indicate your schema_migrations table may not be getting backed up which would lead to the problem you have now.

The ideal solution would be to restore a backup that has all the tables in it correctly -- including schema_migrations.

Even if you decide to find a way around this in the short-term, in the long-term the correct solution is to modify your backup scripts to get all the tables you need, including schema_migrations.

In terms of what to do now, the ideal solution is probaby to backup just that one table (schema_migrations) from your database and import that data into the database you're trying to load now. Then your migrations should no longer be pending.

Doing that with a simple table dump and load script should be fine. The simple postgres gui PgAdmin ( http://www.pgadmin.org/ ) may also provide some basic tools for dumping then loading a single table.

like image 179
Kevin Bedell Avatar answered Oct 25 '22 09:10

Kevin Bedell