Class: Inferno::Utils::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/utils/migration.rb

Instance Method Summary collapse

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/inferno/utils/migration.rb', line 4

def run
  db = Inferno::Application['db.connection']
  migration_path = File.join(Inferno::Application.root, 'lib', 'inferno', 'db', 'migrations')
  Sequel::Migrator.run(db, migration_path)

  if ENV['APP_ENV'] == 'development' # rubocop:disable Style/GuardClause
    schema_path = File.join(Inferno::Application.root, 'lib', 'inferno', 'db', 'schema.rb')
    db.extension :schema_dumper
    File.open(schema_path, 'w') { |f| f.print(db.dump_schema_migration) }
  end
end