I am currently developing a Rails application using a database that was designed before I was aware of Rails existence.
I have currently created some migrations to add some new tables and new columns to existing tables.
I would like to have the migrations to recreate the full database.
Which steps should I follow?
Should I create all the migrations by hand?
EDIT: I am interested in the database schema not in the database contents
I think this will require some manual work.
You can start out by running
rake db:schema:dumpif you do not have the filedb/schema.rbin your project. You probably already have adb/schema.rbfile if you have been using migrations. That file will contain the ruby representation of the database you have configured for development. To get the ruby representation of another database pass in RAILS_ENV to the rake command (ieRAILS_ENV=production rake db:schema:dump)You could then use that
schema.rbfile as a starting point to create new migrations that recreate the preexisting tables. When creating the new migration file make sure that it is named in such a way that it will be run prior to your other migrations.