Enhanced Rails Migrations is a plugin that makes easier rails development in a large team with multiple code branches.
The SolutionThere is a couple of patches against the Edge rails approaching the problem from different angles. You might want to try them unless you work on 1.1.6 or prefer plugins to handle such things.
The plugin monkey-patches ActiveRecord classes to replace the sequential number based rails migration mechanism with the timestamp based one. That allows to avoid name collisions. In addition, it maintains a tracking table of already run migrations instead of the standard single number schema_info. The table is being used for decision whether to run a migration. The biggest difference from the standard way is that migrations below the current schema version are still applied if they have not been applied yet (not in the tracking table).
Important: See the First Run section for details how to use it in existing projects.
CompatibilityThe code has been used mostly on 1.1.6 and it was tested against the edge rails.
InstallationInstall as any other Rails plugin:
ruby script/plugin install svn://rubyforge.org/var/svn/enhanced-mgrtns/enhanced_migrations
UsageThere is no difference in migration usage - use script/generate migration to generate a new migration and rake db:migrate for migration.
schema_version is depreciated. If you need to find the last run migration, use: SELECT MAX(id) FROM migrations_info
First RunIf you are adding the plugin in a middle of the development process, when some migrations have been created and applied, you need to mark those as already run or rake db:migrate would try to apply them again. The plugin contains a sample zero-number migration which queries the DB for the last run migration number and marks all migrations prior to the number as already run in the new tracking table. It also deletes the schema_version table. To use it, copy migrations/000_run_migrations_marker.rb from the project to your rails db/migrate directory.
Enhanced Rails Migrations is released under the MIT license.
The plugin RubyForge page is rubyforge.org/projects/enhanced-mgrtns