Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell what changes 'rake db:migrate' will apply before applying them?

The command rake db:migrate will apply all relevant new migrations to a database and will list in the output the migrations that were applied.

I'd like to know in advance what migrations will be applied so as to note down a list of the changes that are expected in a production environment.

Is there an option I can use in conjunction to rake db:migrate that will show me what changes will be applied without actually applying them?

like image 580
Jon Cram Avatar asked Sep 08 '11 10:09

Jon Cram


People also ask

What does rake db migrate do?

A migration means that you move from the current version to a newer version (as is said in the first answer). Using rake db:migrate you can apply any new changes to your schema. But if you want to rollback to a previous migration you can use rake db:rollback to nullify your new changes if they are incorrectly defined.

How do I view pending migrations in rails?

rails_project theIV$ rake db:abort_if_pending_migrations (in /Users/theIV/Sites/rails_project/) You have 1 pending migrations: 20090828200602 Test Run "rake db:migrate" to update your database then try again. Show activity on this post. Show activity on this post. rake db:version will accomplish this on Rails 2.

How does rails keep track of migrations?

Every time a migration is generated using the rails g migration command, Rails generates the migration file with a unique timestamp. The timestamp is in the format YYYYMMDDHHMMSS . Whenever a migration is run, Rails inserts the migration timestamp into an internal table schema_migrations .

Which command is true to rollback migration in rails?

You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.


1 Answers

Does rake db:migrate:status (rails 3+ only) fit the bill?

like image 170
Benoit Garret Avatar answered Sep 25 '22 10:09

Benoit Garret