phpBB API Documentation
Class

phpbb\db\migrator

class migrator

The migrator is responsible for applying new migrations in the correct order.

Methods

__construct(ContainerInterface $container, config $config, driver_interface $db, tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, helper $helper)

Constructor of the database migrator

set_output_handler(migrator_output_handler_interface $handler)

Set the output handler.

null load_migration_state()

Loads all migrations and their application state from the database.

array get_last_run_migration()

Get an array with information about the last migration run.

null set_migrations(array $class_names)

Sets the list of available migration class names to the given array.

array get_migrations()

Get the list of available migration class names

array get_installable_migrations()

Get the list of available and not installed migration class names

null update()

Runs a single update step from the next migration to be applied.

revert(string $migration)

Runs a single revert step from the last migration installed

bool|string unfulfillable(string $name)

Checks if a migration's dependencies can even theoretically be satisfied.

bool finished()

Checks whether all available, fulfillable migrations have been applied.

bool|array migration_state(string $migration)

Gets a migration state (whether it is installed and to what extent)

null populate_migrations(array $migrations)

This function adds all migrations sent to it to the migrations table

null create_migrations_table()

Creates the migrations table if it does not exist.

static bool is_migration(string $migration)

Check if a class is a migration.

Details

at line 97
public __construct(ContainerInterface $container, config $config, driver_interface $db, tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, helper $helper)

Constructor of the database migrator

Parameters

ContainerInterface $container
config $config
driver_interface $db
tools_interface $db_tools
$migrations_table
$phpbb_root_path
$php_ext
$table_prefix
$tools
helper $helper

at line 129
public set_output_handler(migrator_output_handler_interface $handler)

Set the output handler.

Parameters

migrator_output_handler_interface $handler The output handler

at line 139
public null load_migration_state()

Loads all migrations and their application state from the database.

Return Value

null

at line 174
public array get_last_run_migration()

Get an array with information about the last migration run.

The array contains 'name', 'class' and 'state'. 'effectivelyinstalled' is set and set to true if the last migration was effectivelyinstalled.

Return Value

array

at line 185
public null set_migrations(array $class_names)

Sets the list of available migration class names to the given array.

Parameters

array $class_names An array of migration class names

Return Value

null

at line 203
public array get_migrations()

Get the list of available migration class names

Return Value

array Array of all migrations available to be run

at line 213
public array get_installable_migrations()

Get the list of available and not installed migration class names

Return Value

array

at line 238
public null update()

Runs a single update step from the next migration to be applied.

The update step can either be a schema or a (partial) data update. To check if update() needs to be called again use the finished() method.

Return Value

null

at line 485
public revert(string $migration)

Runs a single revert step from the last migration installed

YOU MUST ADD/SET ALL MIGRATIONS THAT COULD BE DEPENDENT ON THE MIGRATION TO REVERT TO BEFORE CALLING THIS METHOD! The revert step can either be a schema or a (partial) data revert. To check if revert() needs to be called again use the migration_state() method.

Parameters

string $migration String migration name to revert (including any that depend on this migration)

at line 866
public bool|string unfulfillable(string $name)

Checks if a migration's dependencies can even theoretically be satisfied.

Parameters

string $name The class name of the migration

Return Value

bool|string False if fulfillable, string of missing migration name if unfulfillable

at line 902
public bool finished()

Checks whether all available, fulfillable migrations have been applied.

Return Value

bool Whether the migrations have been applied

at line 935
public bool|array migration_state(string $migration)

Gets a migration state (whether it is installed and to what extent)

Parameters

string $migration String migration name to check if it is installed

Return Value

bool|array False if the migration has not at all been installed, array

at line 972
public null populate_migrations(array $migrations)

This function adds all migrations sent to it to the migrations table

THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE!

Parameters

array $migrations Array of migrations (names) to add to the migrations table

Return Value

null

at line 995
public null create_migrations_table()

Creates the migrations table if it does not exist.

Return Value

null

at line 1021
static public bool is_migration(string $migration)

Check if a class is a migration.

Parameters

string $migration A migration class name

Return Value

bool Return true if class is a migration, false otherwise