switch from enhanced migrations plugin to rails timestamped migrations
December 27, 2008 , Written By Surendra Singhi.On our rails 1.2.* project we were using enhanced migrations plugin. Recently we decided to make a switch to rails 2.2.* and wanted to use default UTC based migrations versioning which is a part of the rails core now.
Enhanced migrations plugin uses the table migrations_info to store the migrations information but rails 2.2 uses the table schema_migrations by default. When one does rake db:migrate, the rails code checks whether the schema_migrations table exists or not, if the table is not there, then it is created, and if the schema_info table is present, then this table is populated with all migrations upto the version in the schema_info table. But, since we were using the enhanced migrations plugin, the table schema_info was present but wasn’t being used.
So, to make the switch to rails 2.2.* timestamped migrations before doing regular rake db:migrate the following sql code had to be run, to ensure that schema_migrations table is pre-created, and has the correct list of all migrations which have been run.
create table schema_migrations (version varchar(255) not null primary key);
INSERT INTO schema_migrations select id from migrations_info;
drop table if exists schema_info;