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).
精彩评论