Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
If you are working on more than one development branch you can end up with migrations with the same number when merging.
Which plugins or technique do you use for managing this?
I use a renumbering rake task provided by this "plugin":http://www.sanityinc.com/articles/renumber-rails-migrations
That's a nice plugin! I've been doing it the dirty way with a script like this:
#!/usr/bin/env ruby -w
# keep migration scripts in order
require "fileutils"
scripts = [
"create_users.rb",
"create_roles.rb",
"create_rights.rb",
"create_event_types.rb",
"create_events.rb",
"create_addresses.rb",
"create_states.rb",
"create_regions.rb",
"create_counties.rb",
"create_zipcodes.rb",
"add_regions.rb",
"add_counties.rb",
"add_zipcodes.rb"
]
Dir.chdir("./migrate")
scripts.each_with_index do |s, i|
source = Dir["*_#{s}"].first
prefix = sprintf("%03d", i+1)
begin
FileUtils::mv("#{source}", "#{prefix}_#{s}")
puts "*_#{source} -> #{prefix}_#{s}"
rescue ArgumentError
#puts "*_#{source} is already named properly"
end
end
puts "Done."
Mainly because I can control the order manually, in case there are foreign key constraints that depend on order of table creation. I'll be digging into that plugin though to see what it does.
