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.147 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.146 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.145 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.144 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.143 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.142 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.141 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.140 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.139 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.138 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.137 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.136 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.135 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.134 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.133 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.132 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.131 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.130 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.129 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.128 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb