Sha256: 2b5e36f235e5e4c7458d9769190be6bba07b8b13156d1345790045eaa4f6924a

Contents?: true

Size: 997 Bytes

Versions: 12

Compression:

Stored size: 997 Bytes

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
      Sequel.extension :migration
      Sequel::TimestampMigrator.new(database_connection, PactBroker::DB::MIGRATIONS_DIR).run
    end

    def self.run_data_migrations database_connection
      PactBroker::DB::MigrateData.(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

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.31.0 lib/pact_broker/db.rb
pact_broker-2.30.0 lib/pact_broker/db.rb
pact_broker-2.29.0 lib/pact_broker/db.rb
pact_broker-2.27.6 lib/pact_broker/db.rb
pact_broker-2.27.5 lib/pact_broker/db.rb
pact_broker-2.27.4 lib/pact_broker/db.rb
pact_broker-2.27.3 lib/pact_broker/db.rb
pact_broker-2.27.2 lib/pact_broker/db.rb
pact_broker-2.27.0 lib/pact_broker/db.rb
pact_broker-2.26.1 lib/pact_broker/db.rb
pact_broker-2.26.0 lib/pact_broker/db.rb
pact_broker-2.25.0 lib/pact_broker/db.rb