问题
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?
回答1:
First create a schema.rb file
rake db:schema:dump
Then make a migration ot of it.
class CreateMigration < ActiveRecord::Migration
def self.up
# insert schema.rb here
end
def self.down
end
end
You might also need to create the schema_migrations table, and manually add the timestamp for this migration to it.
来源:https://stackoverflow.com/questions/6220883/rake-is-out-of-synch-with-my-database