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.104 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.103 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.102 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.101 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.100 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.99 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.98 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.97 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.96 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.95 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.94 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.93 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.92 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.91 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.90 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.89 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.88 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.87 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.86 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb
renalware-core-2.0.85 db/migrate/20190607134717_add_ukrdc_modality_code_id_to_modality_descriptions.rb