Sha256: 121ec98d7db584b5378ef5a5c98a1bf7a0419a61edbcdb3e5e6d1eac93fd80f5
Contents?: true
Size: 1.2 KB
Versions: 68
Compression:
Stored size: 1.2 KB
Contents
class AddMissingConstraints < ActiveRecord::Migration def change BitPlayer::ParticipantStatus.all.each do |s| s.destroy! if s.participant.nil? end Group.all.each do |g| g.update!(arm_id: nil) if g.arm.nil? end reversible do |dir| dir.up do execute <<-SQL ALTER TABLE bit_player_participant_statuses ADD CONSTRAINT fk_statuses_participants FOREIGN KEY (participant_id) REFERENCES participants(id) SQL execute <<-SQL ALTER TABLE groups ADD CONSTRAINT fk_groups_arms FOREIGN KEY (arm_id) REFERENCES arms(id) SQL end dir.down do execute <<-SQL ALTER TABLE bit_player_participant_statuses DROP CONSTRAINT IF EXISTS fk_statuses_participants SQL execute <<-SQL ALTER TABLE groups DROP CONSTRAINT IF EXISTS fk_groups_arms SQL end end change_column_null :arms, :has_woz, false change_column_null :emotional_ratings, :rating, false change_column_null :moods, :rating, false change_column_null :participant_login_events, :participant_id, false end end
Version data entries
68 entries across 68 versions & 1 rubygems