Module: PactBroker::DB
- Defined in:
- lib/pact_broker/db.rb,
lib/pact_broker/db/clean.rb,
lib/pact_broker/db/models.rb,
lib/pact_broker/db/migrate.rb,
lib/pact_broker/db/version.rb,
lib/pact_broker/db/migrate_data.rb,
lib/pact_broker/db/advisory_lock.rb,
lib/pact_broker/db/log_quietener.rb,
lib/pact_broker/tasks/clean_task.rb,
lib/pact_broker/db/clean/selector.rb,
lib/pact_broker/tasks/version_task.rb,
lib/pact_broker/db/clean_incremental.rb,
lib/pact_broker/db/seed_example_data.rb,
lib/pact_broker/db/validate_encoding.rb,
lib/pact_broker/tasks/migration_task.rb,
lib/pact_broker/tasks/data_migration_task.rb,
lib/pact_broker/db/data_migrations/helpers.rb,
lib/pact_broker/db/delete_overwritten_data.rb,
lib/pact_broker/db/table_dependency_calculator.rb,
lib/pact_broker/db/data_migrations/create_branches.rb,
lib/pact_broker/tasks/delete_overwritten_data_task.rb,
lib/pact_broker/db/data_migrations/set_webhook_uuid.rb,
lib/pact_broker/db/data_migrations/migrate_integrations.rb,
lib/pact_broker/db/data_migrations/set_webhooks_enabled.rb,
lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb,
lib/pact_broker/db/data_migrations/set_interactions_counts.rb,
lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb,
lib/pact_broker/db/data_migrations/set_pacticipant_main_branch.rb,
lib/pact_broker/db/data_migrations/set_pacticipant_display_name.rb,
lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb,
lib/pact_broker/db/data_migrations/delete_deprecated_webhook_executions.rb,
lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb,
lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb,
lib/pact_broker/db/data_migrations/set_created_at_for_latest_verifications.rb,
lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb,
lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb,
lib/pact_broker/db/data_migrations/set_consumer_version_order_for_pact_publications.rb,
lib/pact_broker/db/data_migrations/migrate_pact_version_provider_tag_successful_verifications.rb
Defined Under Namespace
Modules: DataMigrations
Classes: AdvisoryLock, Clean, CleanIncremental, CleanTask, ConnectionConfigurationError, DataMigrationTask, DeleteOverwrittenData, DeleteOverwrittenDataTask, LogQuietener, Migrate, MigrateData, MigrationTask, SeedExampleData, TableDependencyCalculator, ValidateEncoding, Version, VersionTask
Constant Summary
collapse
- MIGRATIONS_DIR =
File.expand_path("../../../db/migrations", __FILE__)
Class Method Summary
collapse
Class Method Details
.check_current(database_connection, options = {}) ⇒ Object
35
36
37
|
# File 'lib/pact_broker/db.rb', line 35
def self.check_current database_connection, options = {}
Sequel::TimestampMigrator.check_current(database_connection, PactBroker::DB::MIGRATIONS_DIR, options)
end
|
.connection ⇒ Object
18
19
20
|
# File 'lib/pact_broker/db.rb', line 18
def self.connection
@connection
end
|
.connection=(connection) ⇒ Object
14
15
16
|
# File 'lib/pact_broker/db.rb', line 14
def self.connection= connection
@connection = connection
end
|
.each_integration_model ⇒ Object
45
46
47
48
49
|
# File 'lib/pact_broker/db/models.rb', line 45
def self.each_integration_model
INTEGRATIONS_TABLES.each do | model |
yield model
end
end
|
.is_current?(database_connection, options = {}) ⇒ Boolean
31
32
33
|
# File 'lib/pact_broker/db.rb', line 31
def self.is_current? database_connection, options = {}
Sequel::TimestampMigrator.is_current?(database_connection, PactBroker::DB::MIGRATIONS_DIR, options)
end
|
.mysql? ⇒ Boolean
64
65
66
|
# File 'lib/pact_broker/db.rb', line 64
def self.mysql?
connection.adapter_scheme =~ /mysql/
end
|
.run_data_migrations(database_connection) ⇒ Object
27
28
29
|
# File 'lib/pact_broker/db.rb', line 27
def self.run_data_migrations database_connection
PactBroker::DB::MigrateData.(database_connection)
end
|
.run_migrations(database_connection, options = {}) ⇒ Object
22
23
24
25
|
# File 'lib/pact_broker/db.rb', line 22
def self.run_migrations database_connection, options = {}
Sequel.extension :migration
Sequel::TimestampMigrator.new(database_connection, PactBroker::DB::MIGRATIONS_DIR, options).run
end
|
.set_mysql_strict_mode_if_mysql ⇒ Object
60
61
62
|
# File 'lib/pact_broker/db.rb', line 60
def self.set_mysql_strict_mode_if_mysql
connection.run("SET sql_mode='STRICT_TRANS_TABLES';") if mysql?
end
|
.truncate(database_connection, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/pact_broker/db.rb', line 39
def self.truncate database_connection, options = {}
exceptions = options[:except] || []
TableDependencyCalculator.call(database_connection).each do | table_name |
if !exceptions.include?(table_name)
begin
database_connection[table_name].truncate
rescue StandardError => _ex
puts "Could not truncate table #{table_name}"
end
end
end
end
|
.validate_connection_config ⇒ Object
.version(database_connection) ⇒ Object
52
53
54
|
# File 'lib/pact_broker/db.rb', line 52
def self.version database_connection
PactBroker::DB::Version.call(database_connection)
end
|