开发者

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

开发者 https://www.devze.com 2023-02-20 17:34 出处:网络
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

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

精彩评论

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