Class humhub\commands\MigrateController

Inheritancehumhub\commands\MigrateController » yii\console\controllers\MigrateController

Manages application migrations.

A migration means a set of persistent changes to the application environment that is shared among different developers. For example, in an application backed by a database, a migration may refer to a set of changes to the database, such as creating a new table, adding a new table column.

This command provides support for tracking the migration history, upgrading or downloading with migrations, and creating new migration skeletons.

The migration history is stored in a database table named as \humhub\commands\migrationTable. The table will be automatically created the first time this command is executed, if it does not exist. You may also manually create it as follows:

CREATE TABLE migration (
    version varchar(180) PRIMARY KEY,
    apply_time integer
)

Below are some common usages of this command:

# creates a new migration named 'create_user_table'
yii migrate/create create_user_table

# applies ALL new migrations
yii migrate

# reverts the last applied migration
yii migrate/down

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$includeModuleMigrations boolean Also include migration paths of all enabled modules humhub\commands\MigrateController
$migrationPath string The directory storing the migration classes. humhub\commands\MigrateController

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$migrationPathMap array humhub\commands\MigrateController

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createMigration() Creates a new migration instance. humhub\commands\MigrateController
getMigrationPaths() Returns the migration paths of all enabled modules humhub\commands\MigrateController
getNewMigrations() Returns the migrations that are not applied. humhub\commands\MigrateController

Property Details

$includeModuleMigrations public property

Also include migration paths of all enabled modules

$migrationPath public property

The directory storing the migration classes. This can be either a path alias or a directory.

public string $migrationPath '@humhub/migrations'
$migrationPathMap protected property
protected array $migrationPathMap = []

Method Details

createMigration() protected method

Creates a new migration instance.

protected \yii\db\MigrationInterface createMigration ( $class )
$class string

The migration class name

return \yii\db\MigrationInterface

The migration instance

getMigrationPath() public method

Returns the migration path of a given migration.

A map containing the path=>migration will be created by getNewMigrations method.

public \humhub\commands\type getMigrationPath ( $migration )
$migration \humhub\commands\type
throws \yii\console\Exception
getMigrationPaths() protected method

Returns the migration paths of all enabled modules

protected array getMigrationPaths ( )
getNewMigrations() protected method

Returns the migrations that are not applied.

protected array getNewMigrations ( )
return array

List of new migrations

options() public method

public void options ( $actionID )
$actionID
stderr() public method

public void stderr ( $string )
$string
stdout() public method

public void stdout ( $string )
$string
webMigrateAll() public static method

Executes all pending migrations

public static string webMigrateAll ( )
return string

Output

webMigrateUp() public static method

Executes migrations in a specific folder

public static string webMigrateUp ( $migrationPath )
$migrationPath string
return string

Output