我想使用 STEP 参数将我的数据库回滚到 Rails 上的某个版本,但我不知道我应该回滚多少步,所以我想检查迁移日志。我可以在 Rails (v3.2.13) 上这样做吗?
问问题
5760 次
2 回答
23
尝试以下操作:
rake db:migrate:status
它将为您提供以下输出,up
表示迁移已运行,down
尚未运行:
Status Migration ID Migration Name
--------------------------------------------------
up 20120328154345 Devise create users
up 20120331182021 Create websites
于 2013-04-27T05:11:35.053 回答
2
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
于 2013-04-27T05:13:23.713 回答