Migrations for an Existing DB

This isn't a full solution, but some tips based on having to reconstruct migrations on a project where the original developers didn't consistently use migrations (since I've not had to deal [yet] with a true legacy db in Rails).

put the legacy schema (I don't know if you can just point your database.yml at production and db:schema:dump) into your migration 1:
db/migrate/001_legacy_schema.rb

(I think there's a :force=>false on the create table that might help, too)

Put the down migration as:
   def self.down
     raise IrreversibleMigration, "Can't erase Legacy schema"
   end

Manually, create the schema_information table in production and set the version column of the only row to be 1.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

Right, only the migrations numbered from (select version from schema_information)+1 up to the highest prefix in db/migrate/*.rb will be run. So 001_legacy_schema.rb would exist more as documentation than anything else and the IrreversibleMigration keeps the Migrator from ever going from 1 back to 0 (which is usually an empty schema (with the possible exception of the schema_information table itself that the migration creates and maintains).

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com