Last active
November 13, 2015 18:34
-
-
Save robdimarco/4bd23b43a35121cdc251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddProfileIdToTestimonials < ActiveRecord::Migration | |
def change | |
add_column :testimonials, :profile_ids, :integer, array: true | |
reversible do |dir| | |
dir.up do | |
execute <<-SQL | |
update testimonials set profile_ids = (select array_agg(profiles.id) from profiles | |
where profiles.accounts_id = testimonials.account_id;) | |
SQL | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment