Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created November 9, 2011 13:02
Show Gist options
  • Save brandon-beacher/1351355 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1351355 to your computer and use it in GitHub Desktop.
maximum_id = 2
[:customer_a, :customer_b].each_with_index do |database_name, index|
id_offset = index * maximum_id
ActiveRecord::Base.connection.execute %{
insert into people
select
`id` + #{id_offset},
`name`,
#{database_name}
from #{database_name}.people
%}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment