Class: ReeMigrator::MigrateDb

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_migrator/package/ree_migrator/functions/migrate_db.rb

Constant Summary collapse

SCHEMA_MIGRATIONS =
"schema_migrations"
DATA_MIGRATIONS =
"data_migrations"

Instance Method Summary collapse

Instance Method Details

#call(db_connection, migrations_yml_path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ree_lib/packages/ree_migrator/package/ree_migrator/functions/migrate_db.rb', line 16

def call(db_connection, migrations_yml_path)
  migrations_yml_dir = File.dirname(migrations_yml_path)
  schema_migrations_path = File.join(migrations_yml_dir, SCHEMA_MIGRATIONS)
  data_migrations_path = File.join(migrations_yml_dir, DATA_MIGRATIONS)

  logger.info("Applying schema and data migrations for #{db_connection.opts[:database]} database")

  create_migrations_table(db_connection)

  apply_migrations(
    db_connection,
    migrations_yml_path,
    schema_migrations_path,
    data_migrations_path
  )

  nil
end