我想使用STEP参数将我的数据库回滚到某个Rails版本,但我不知道应该回滚多少步骤,所以我想检查迁移日志。我能在Rails (v3.2.13)上做到这一点吗?
发布于 2013-04-27 13:11:35
尝试以下操作:
rake db:migrate:status它将给出以下输出,up表示迁移已运行,down尚未运行:
Status Migration ID Migration Name
--------------------------------------------------
up 20120328154345 Devise create users
up 20120331182021 Create websites发布于 2013-04-27 13:13:24
您可以尝试通过以下方式获取迁移版本
> 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,........或者,您可以使用要回滚到的特定迁移的时间戳
rake db:migrate:down VERSION=时间戳
https://stackoverflow.com/questions/16248514
复制相似问题