Sha256: 4c37065b72a1a4f86b48be6e346a309dc855af2ed7ca35971f3048ac42efc8fc

Contents?: true

Size: 1.22 KB

Versions: 84

Compression:

Stored size: 1.22 KB

Contents

class AddUKRDCModalityCodeIdToModalityDescriptions < ActiveRecord::Migration[5.2]
  def change
    # add_column :modality_descriptions, :ukrdc_modality_code_id, :integer
    add_reference :modality_descriptions,
                  :ukrdc_modality_code,
                  foreign_key: true

    reversible do |direction|
      direction.up do
        # Obviously this 'data migration' will only apply if modality_descriptions are already seeded!
        connection.execute(<<-SQL.squish)
          update renalware.modality_descriptions set ukrdc_modality_code_id = (select id from renalware.ukrdc_modality_codes where qbl_code = '19') where name = 'PD';
          update renalware.modality_descriptions set ukrdc_modality_code_id = (select id from renalware.ukrdc_modality_codes where qbl_code = '1') where name = 'HD';
          update renalware.modality_descriptions set ukrdc_modality_code_id = (select id from renalware.ukrdc_modality_codes where qbl_code = '29') where name = 'Transplant';
          update renalware.modality_descriptions set ukrdc_modality_code_id = (select id from renalware.ukrdc_modality_codes where qbl_code = '900') where name = 'vCKD';
        SQL
      end
      direction.down do
        # noop
      end
    end
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
renalware-core-2.0.127 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.126 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.125 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.124 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.123 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.121 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.120 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.119 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.118 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.117 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.116 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.115 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.113 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.112 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.111 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.110 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.109 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.108 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.106 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.105 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb