I want to rollback my database to a certain version on Rails using the STEP parameter, but I don't know how many steps should i rollback so I want to check the migration log. Can I do that on Rails (v3.2.13)?
我想使用STEP参数将数据库回滚到Rails上的某个版本,但是我不知道应该回滚多少步,因此我想检查迁移日志。我可以在Rails上做吗(v3.2.13)?
2 个解决方案
#1
16
Try the following:
试试以下:
rake db:migrate:status
It will give you the following output, up
meaning migration has been run, down
hasn't been run yet:
它会给你下面的输出,也就是说迁移已经运行了,下面还没有运行:
Status Migration ID Migration Name
--------------------------------------------------
up 20120328154345 Devise create users
up 20120331182021 Create websites
#2
1
You can try to get migration versions by
您可以尝试获得迁移版本
> ActiveRecord::Migrator.current_version
(38.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
=> 20130403113845
1.9.3-p392 :002 > ActiveRecord::Migrator.get_all_versions
(0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
=> [20130327085819, 20130327085820, 20130327085821, 20130327085822, 20130327085823, 20130327085824, 20130327085825, 20130327085826, 20130327085827, 20130327085828, 20130327085829, 20130327085830,........
or you can use the time stamp of the specific migration upto which you want to rollback and use
或者您可以使用要回滚和使用的特定迁移的时间戳
rake db:migrate:down VERSION= timestamp
rake db:迁移:VERSION =时间戳
#1
16
Try the following:
试试以下:
rake db:migrate:status
It will give you the following output, up
meaning migration has been run, down
hasn't been run yet:
它会给你下面的输出,也就是说迁移已经运行了,下面还没有运行:
Status Migration ID Migration Name
--------------------------------------------------
up 20120328154345 Devise create users
up 20120331182021 Create websites
#2
1
You can try to get migration versions by
您可以尝试获得迁移版本
> ActiveRecord::Migrator.current_version
(38.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
=> 20130403113845
1.9.3-p392 :002 > ActiveRecord::Migrator.get_all_versions
(0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
=> [20130327085819, 20130327085820, 20130327085821, 20130327085822, 20130327085823, 20130327085824, 20130327085825, 20130327085826, 20130327085827, 20130327085828, 20130327085829, 20130327085830,........
or you can use the time stamp of the specific migration upto which you want to rollback and use
或者您可以使用要回滚和使用的特定迁移的时间戳
rake db:migrate:down VERSION= timestamp
rake db:迁移:VERSION =时间戳