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.1.1 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.1.0 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.167 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.166 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.165 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.164 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.163 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.162 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.161 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.160 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.159 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.158 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.157 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.156 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.155 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.153 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.152 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.151 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.149 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.148 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb