Sha256: 50f8a4ed1344012a6eead1d80f478ae6f6cbc45e3b399d982b9ac4a87a260de6

Contents?: true

Size: 1 KB

Versions: 15

Compression:

Stored size: 1 KB

Contents

require 'sequel'
require 'pact_broker/db/validate_encoding'
require 'pact_broker/db/migrate'
require 'pact_broker/db/migrate_data'

Sequel.datetime_class = DateTime

module PactBroker
  module DB

    MIGRATIONS_DIR = File.expand_path("../../../db/migrations", __FILE__)

    def self.connection= connection
      @connection = connection
    end

    def self.connection
      @connection
    end

    def self.run_migrations database_connection, options = {}
      Sequel.extension :migration
      Sequel::TimestampMigrator.new(database_connection, PactBroker::DB::MIGRATIONS_DIR, options).run
    end

    def self.run_data_migrations database_connection
      PactBroker::DB::MigrateData.(database_connection)
    end

    def self.validate_connection_config
      PactBroker::DB::ValidateEncoding.(connection)
    end

    def self.set_mysql_strict_mode_if_mysql
      connection.run("SET sql_mode='STRICT_TRANS_TABLES';") if mysql?
    end

    def self.mysql?
      connection.adapter_scheme =~ /mysql/
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pact_broker-2.55.0 lib/pact_broker/db.rb
pact_broker-2.54.0 lib/pact_broker/db.rb
pact_broker-2.53.0 lib/pact_broker/db.rb
pact_broker-2.52.2 lib/pact_broker/db.rb
pact_broker-2.52.1 lib/pact_broker/db.rb
pact_broker-2.52.0 lib/pact_broker/db.rb
pact_broker-2.51.0 lib/pact_broker/db.rb
pact_broker-2.50.1 lib/pact_broker/db.rb
pact_broker-2.50.0 lib/pact_broker/db.rb
pact_broker-2.49.0 lib/pact_broker/db.rb
pact_broker-2.48.0 lib/pact_broker/db.rb
pact_broker-2.47.1 lib/pact_broker/db.rb
pact_broker-2.47.0 lib/pact_broker/db.rb
pact_broker-2.46.0 lib/pact_broker/db.rb
pact_broker-2.45.0 lib/pact_broker/db.rb