Skip to content

Commit

Permalink
chore: ensure migrations have been performed before running specs
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 3, 2021
1 parent 31ba04a commit 627bfc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pact_broker/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def self.is_current? database_connection, options = {}
Sequel::TimestampMigrator.is_current?(database_connection, PactBroker::DB::MIGRATIONS_DIR, options)
end

def self.check_current database_connection, options = {}
Sequel::TimestampMigrator.check_current(database_connection, PactBroker::DB::MIGRATIONS_DIR, options)
end

def self.truncate database_connection, options = {}
exceptions = options[:except] || []
TableDependencyCalculator.call(database_connection).each do | table_name |
Expand Down
1 change: 1 addition & 0 deletions spec/support/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
require 'pact_broker/db'
raise "Wrong environment!!! Don't run this script!! ENV['RACK_ENV'] is #{ENV['RACK_ENV']} and RACK_ENV is #{RACK_ENV}" if ENV['RACK_ENV'] != 'test'
PactBroker::DB.connection = PactBroker::Database.database = DB::PACT_BROKER_DB
PactBroker::DB.check_current(PactBroker::DB.connection)

0 comments on commit 627bfc3

Please sign in to comment.