Rake与我的数据库不同步 [英] Rake is out of synch with my Database
问题描述
我已经继承了一个Ruby on Rails项目,其中程序员没有使用rake来创建数据库模式,所以似乎很不同步,有办法纠正这个问题吗?
I have inherited a Ruby on Rails project where the programmer didn't use rake to create the db schema, so it seems very out of synch, is there a way to rectify this?
推荐答案
首先创建一个schema.rb文件
First create a schema.rb file
rake db:schema:dump
rake db:schema:dump
Then make a migration ot of it.
c $ c> class CreateMigration< ActiveRecord :: Migration
def self.up
#insert schema.rb here
end
def self.down
end
end
class CreateMigration < ActiveRecord::Migration
def self.up
# insert schema.rb here
end
def self.down
end
end
您可能还需要创建schema_migrations表,并手动向此迁移添加时间戳。
You might also need to create the schema_migrations table, and manually add the timestamp for this migration to it.
这篇关于Rake与我的数据库不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!