我目前正在开发Rails 4应用程序,并且在过去几个月中我收集了大量独特的迁移文件,这些文件可以反转它们自己的更改等。
由于我没有在这个开发阶段重置数据库的问题,我想我可能会清理一下这个混乱。
是否有重做所有迁移文件的方法,同时还允许删除某些迁移文件并扩展其他文件?Rails 4:将所有迁移重新迁移到Schema
我很欣赏每个答案!
实施例(编辑)
我有两个迁移文件:
- 20160911071103_create_items.rb
- 20160918085621_add_cached_votes_to_items.rb
两者都已迁移。前
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.integer :user_id
t.timestamps null: false
end
end
end
我的目标<
一号文件将包括由第二个文件直接在第一个文件并删除第二所添加的列。
一号文件作为你的意思是你后
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.integer :user_id
t.integer :cached_votes
t.timestamps null: false
end
end
end
不知道您重做所有迁移文件**的含义是什么?你可以给你的应用程序的实例,我认为这会更有意义! – dp7
@dkp增加了一个例子 – Gugubaight
'rake db:reset' – jamesjaya