Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Best technique for managing migrations across development branches?
3 Posts
Best technique for managing migrations across development branches?

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.

I use a renumbering rake task provided by this "plugin":http://www.sanityinc.com/articles/renumber-rails-migrations

Person
Sr. Ruby & Rails Consultant For Hire
Sign In To Rate Post

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?

3 Posts
Login to add your message