Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to view Rails Migration output

Is there an easy way to see the actual SQL generated by a rails migration?

I have a situation where a migration to change a column type worked on my local development machine by partially failed on the production server.

My postgreSQL versions are different between local and production (7 on production, 8 on local) so I'm hoping by looking at the SQL generated on the successful migration locally I can work out a SQL statement to run on production to fix things....

like image 730
Ganesh Shankar Avatar asked Apr 14 '10 00:04

Ganesh Shankar


People also ask

How can I check my rails migration status?

To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one.

How rails db Migrate works?

When you run db:migrate, rails will check a special table in the database which contains the timestamp of the last migration applied to the database. It will then apply all of the migrations with timestamps after that date and update the database table with the timestamp of the last migration.

Can you edit a migration file rails?

If you have already run the migration then you cannot just edit the migration and run the migration again: Rails thinks it has already run the migration and so will do nothing when you run rake db:migrate.

What does Add_index do in rails?

It adds a multi-column index on columns one and two in resources table. The advantage of multi-column index is that it helps when you have a query with conditions on those multiple columns.


1 Answers

Look at the log files: log/development.log locally vs log/production.log on your server.

like image 125
François Beausoleil Avatar answered Oct 13 '22 01:10

François Beausoleil