The new migration we're performing, typically called from the knex.migrate
interface on the main knex
object. Passes the knex
instance performing
the migration.
Initializes the migration, taking an optional config
object,
for things like the tableName
.
Ensures that the proper table has been created, dependent on the migration config settings.
Ensures a folder for the migrations exist, dependent on the migration config settings.
Create the migration table, if it doesn't already exist.
Migrates to the latest configuration.
Rollback the last "batch" of migrations that were run.
Run a batch of current migrations, in sequence.
Retrieves and returns the current migration version
we're on, as a promise. If there aren't any migrations run yet,
return "none" as the value for the currentVersion
.
Creates a new migration, with a given name.
Lists all available migration versions, as a sorted array.
Lists all migrations that have been completed for the current db, as an array.
Gets the migration list from the specified migration directory, as well as the list of completed migrations to check what should be run.
Generates the stub template for the current migration, returning a compiled template.
Write a new migration to disk, using the config and generated filename,
passing any variables
given in the config to the template.
Get the last batch of migrations, by name, ordered by insert id in reverse order.
Returns the latest batch number.
Runs a batch of migrations
in a specified direction
,
saving the appropriate database information as the migrations are run.
We're going to run each of the migrations in the current "up"
Validates some migrations by requiring and checking for an up
and down
function,
returning an array with the item
and migration
require.
Validates that migrations are present in the appropriate directories.
Gets the current migration.
Parse the version, which really only needs to be the timestamp of the migration we wish to migrate to.
Get a date object in the correct format, without requiring a full out library like "moment.js".
Ensure that we have 2 places for each of the date segments
Dasherize the string.
Migrate