Sha256: 88858de0cd35f96f189186b1ab8424a34038b4f9be8f79006cd1278f4481f62f

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'pact_broker/db/data_migrations/helpers'

module PactBroker
  module DB
    module DataMigrations
      class SetExtraColumnsForTags
        extend Helpers

        def self.call(connection)
          if columns_exist?(connection, :tags, [:version_id, :pacticipant_id]) &&
              columns_exist?(connection, :versions, [:id, :pacticipant_id])
            connection[:tags].where(pacticipant_id: nil).update(
              pacticipant_id: connection[:versions].select(:pacticipant_id)
                                .where(Sequel[:versions][:id] => Sequel[:tags][:version_id])
            )
          end

          if columns_exist?(connection, :tags, [:version_id, :version_order]) &&
              columns_exist?(connection, :versions, [:id, :order])
            connection[:tags].where(version_order: nil).update(
              version_order: connection[:versions].select(:order)
                                .where(Sequel[:versions][:id] => Sequel[:tags][:version_id])
            )
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb
pact_broker-2.79.0 lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb