Skip to content

Instantly share code, notes, and snippets.

@robdimarco
Last active November 13, 2015 18:34
Show Gist options
  • Save robdimarco/4bd23b43a35121cdc251 to your computer and use it in GitHub Desktop.
Save robdimarco/4bd23b43a35121cdc251 to your computer and use it in GitHub Desktop.
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