Class: PactBroker::DB::DataMigrations::MigrateWebhookHeaders
- Inherits:
-
Object
- Object
- PactBroker::DB::DataMigrations::MigrateWebhookHeaders
show all
- Extended by:
- Helpers
- Defined in:
- lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb
Class Method Summary
collapse
Methods included from Helpers
column_exists?, columns_exist?
Class Method Details
.call(connection) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb', line 9
def self.call(connection)
if columns_exist?(connection)
connection[:webhook_headers].for_update.each do | |
webhook = connection[:webhooks].for_update.where(id: [:webhook_id]).first
= webhook[:headers] ? JSON.parse(webhook[:headers]) : {}
[[:name]] = [:value]
connection[:webhooks].where(id: webhook[:id]).update(headers: .to_json)
connection[:webhook_headers].where().delete
end
end
end
|
.columns_exist?(connection) ⇒ Boolean
21
22
23
24
25
26
|
# File 'lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb', line 21
def self.columns_exist?(connection)
column_exists?(connection, :webhooks, :headers) &&
column_exists?(connection, :webhook_headers, :name) &&
column_exists?(connection, :webhook_headers, :value) &&
column_exists?(connection, :webhook_headers, :webhook_id)
end
|