I recently hit upon the Enhanced Migrations plugin by Revolution on Rails. Works great when you develop on branches. The #dump_schema_information method of ActiveRecord::ConnectionAdapters::SchemaStatements only dumps the most recently migration file. Since each migration is now a separate entry in the migrations_info table, we can’t report only the latest one.

To this end, I generated the following diff:


1 $ svn diff vendor
2 Index: vendor/plugins/enhanced_migrations/lib/enhanced_migrations.rb
3 ===============
4 - vendor/plugins/enhanced_migrations/lib/enhanced_migrations.rb (revision 7767)
5 + vendor/plugins/enhanced_migrations/lib/enhanced_migrations.rb (working copy)
6 </span><span class="er"> -58,8 +58,8 </span><span class="er">
7
8 ActiveRecord::ConnectionAdapters::SchemaStatements.send(:define_method, :dump_schema_information) do
9 begin
10if (current_schema = ActiveRecord::Migrator.current_version) > 0
11return "INSERT INTO #{ActiveRecord::Migrator.schema_info_table_name} VALUES (#{current_schema}, NOW"
12 + select_all("SELECT * FROM #{ActiveRecord::Migrator.schema_info_table_name} ORDER BY created_at, id").map do |migration|
13 + "INSERT INTO #{ActiveRecord::Migrator.schema_info_table_name} VALUES;\n"
14 end
15 rescue ActiveRecord::StatementInvalid
16 # No Schema Info

Hope this is useful for other people.

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on