R6 class for management of database migration

Value

data frame all migrations, including file name, order and execution status Get connection handler

See also

ConnectionHandler for information on returned class

Public fields

migrationPath

Path migrations exist in

databaseSchema

Path migrations exist in

packageName

packageName, can be null

tablePrefix

tablePrefix, can be empty character vector

packageTablePrefix

packageTablePrefix, can be empty character vector

Methods


Method new()

Usage

DataMigrationManager$new(
  connectionDetails,
  databaseSchema,
  tablePrefix = "",
  packageTablePrefix = "",
  migrationPath,
  packageName = NULL,
  migrationRegexp = .defaultMigrationRegexp
)

Arguments

connectionDetails

DatabaseConnector connection details object

databaseSchema

Database Schema to execute on

tablePrefix

Optional table prefix for all tables (e.g. plp, cm, cd etc)

packageTablePrefix

A table prefix when used in conjunction with other package results schema, e.g. "cd_", "sccs_", "plp_", "cm_"

migrationPath

Path to location of migration sql files. If in package mode, this should just be a folder (e.g. "migrations") that lives in the location "sql/sql_server" (and) other database platforms. If in folder model, the folder must include "sql_server" in the relative path, (e.g if migrationPath = 'migrations' then the folder 'migrations/sql_server' should exists)

packageName

If in package mode, the name of the R package

migrationRegexp

(Optional) regular expression pattern default is (Migration_([0-9]+))-(.+).sql Migration table exists


Method migrationTableExists()

Check if migration table is present in schema

Usage

DataMigrationManager$migrationTableExists()

Returns

boolean Get path of migrations


Method getMigrationsPath()

Get path to sql migration files

Usage

DataMigrationManager$getMigrationsPath(dbms = "sql server")

Arguments

dbms

Optionally specify the dbms that the migration fits under Get status of result model


Method getStatus()

Get status of all migrations (executed or not)

Usage

DataMigrationManager$getStatus()


Method getConnectionHandler()

Return connection handler instance

Usage

DataMigrationManager$getConnectionHandler()

Returns

ConnectionHandler instance Check migrations in folder


Method check()

Check if file names are valid for migrations Execute Migrations

Usage

DataMigrationManager$check()


Method executeMigrations()

Execute any unexecuted migrations

Usage

DataMigrationManager$executeMigrations(stopMigrationVersion = NULL)

Arguments

stopMigrationVersion

(Optional) Migrate to a specific migration number isPackage


Method isPackage()

is a package folder structure or not finalize

Usage

DataMigrationManager$isPackage()


Method finalize()

close database connection

Usage

DataMigrationManager$finalize()


Method clone()

The objects of this class are cloneable with this method.

Usage

DataMigrationManager$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.