简体   繁体   中英

How to generate migration files using schema.rb

Suppose I have a Big and Ugly schema.rb, and no migrations, what is the best way of creating them, besides doing this with ctr+c/crt+v. Plus I need them to be considered as allready migrated :). Consider that this need to be generated in rails 2.3.5 env :(.

生成一个迁移,然后将schema.rb代码(不带ActiveRecord::Schema.define(:version => x) doend )复制到upchange方法中。

The only option you have is to generate the database from your schema.rb file using the command rake db:schema:load . Just be careful as rake db:schema:load will delete data on your production server.

If you look at the schema.rb file you will notice it only has the timestamp of the last migration, which is the version of the schema, and the commands required to replicate it. You can create a single migration from it, and make all the future changes from there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM