Class: PactBroker::DB::DataMigrations::SetCreatedAtForLatestPactPublications

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb

Class Method Summary collapse

Class Method Details

.call(connection) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb', line 7

def self.call connection
  # pact ordering goes by creation date of the consumer version
  connection[:latest_pact_publication_ids_for_consumer_versions]
  query = "UPDATE latest_pact_publication_ids_for_consumer_versions
          SET created_at = (SELECT created_at
            FROM versions
            WHERE id = latest_pact_publication_ids_for_consumer_versions.consumer_version_id)
          WHERE created_at IS NULL"
  connection.run(query)
end

.columns_exist?(connection) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb', line 18

def self.columns_exist?(connection)
  column_exists?(connection, :latest_pact_publication_ids_for_consumer_versions, :created_at) &&
    column_exists?(connection, :pact_publications, :created_at)
end