hensei-api/db/data/20230702035600_populate_remix_flag_on_parties.rb
Justin Edmund 5c8955d0cc
Allow users to delete parties with remixes (#111)
There was a bug that prevented users from deleting parties with remixes, because the source party reference was not being nulled.

We fixed that with `dependent: :nullify` but also added a boolean key to the parties database to track if a party is a remix or not. This way, if a party is flagged as a remix but the source party is null, we know that the original party was deleted and can message this on the frontend.
2023-07-01 21:37:11 -07:00

15 lines
301 B
Ruby

# frozen_string_literal: true
class PopulateRemixFlagOnParties < ActiveRecord::Migration[7.0]
def up
Party.find_each do |party|
party.update(remix: party.source_party_id.present?)
end
end
def down
Party.find_each do |party|
party.update(remix: false)
end
end
end