Reputation: 9436
Is there a way to generate a migration file or db schema file from an existing RoR model? I lost my original migration files and the db has been deleted and I don't want to write either by hand.
Upvotes: 1
Views: 307
Reputation: 902
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).
Upvotes: 0
Reputation: 6585
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.
Upvotes: 1