Is there a way to know what all migrations have been applied to Rails database?
I am looking for a command-line option, rather than checking the schema_migrations
table in the database.
rake db:version
will give you the current "schema version number" which should match the filename of the last migration that was executed.
To check the status of specific migrations, you can use the following Rake task:
rails db:migrate:status
This will output a table with the status of up
or down
for each migration:
Status Migration ID Migration Name
--------------------------------------------------
up migration_id migration_name
In your case, you can check if you have any migration not applied:
rails db:migrate:status | grep down
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With