开发者

How do I generate the DB schema or migration files for an existing RoR model

Is there a way to generate a migration file or db schema file from an existing RoR model? I lost my original migration files a开发者_StackOverflow中文版nd the db has been deleted and I don't want to write either by hand.


You should have a db/schema.rb file that is created after your migrations have been run. If you don't have this file in your repo and you don't have a db backup then there is nothing ActiveRecord can do for you.


It doesn't seem like it would be possible to me. An ActiveRecord model's attributes are determined by the database schema. There is not usually any code within the model that explicitly states what the model consists of (except for associations).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜