Sha256: 182073b24796e1845086a37ed5c641686253d08cfc1ce9b2a9b868b9c59c4325

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

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].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].update(
              version_order: connection[:versions].select(:order)
                                .where(Sequel[:versions][:id] => Sequel[:tags][:version_id])
            )
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-2.78.1 lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb
pact_broker-2.78.0 lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb
pact_broker-2.77.0 lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb