PHP Class yii\mongodb\console\controllers\MigrateController

This is an analog of MigrateController for MongoDB. 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 MongoDB collection named as [[migrationCollection]]. This collection will be automatically created the first time this command is executed, if it does not exist. In order to enable this command you should adjust the configuration of your console application: php return [ ... 'controllerMap' => [ 'mongodb-migrate' => 'yii\mongodb\console\controllers\MigrateController' ], ]; Below are some common usages of this command: php # creates a new migration named 'create_user_collection' yii mongodb-migrate/create create_user_collection # applies ALL new migrations yii mongodb-migrate # reverts the last applied migration yii mongodb-migrate/down Since 2.1.2, in case of usage Yii version >= 2.0.10, you can use namespaced migrations. In order to enable this feature you should configure [[migrationNamespaces]] property for the controller at application configuration: php return [ 'controllerMap' => [ 'mongodb-migrate' => [ 'class' => 'yii\mongodb\console\controllers\MigrateController', 'migrationNamespaces' => [ 'app\migrations', 'some\extension\migrations', ], 'migrationPath' => null, // allows to disable not namespaced migration completely ], ], ];
Since: 2.0
Author: Klimov Paul ([email protected])
Inheritance: extends yii\console\controllers\BaseMigrateController
Afficher le fichier Open project: yiisoft/yii2-mongodb Class Usage Examples

Méthodes publiques

Свойство Type Description
$db the DB connection object or the application component ID of the DB connection.
$migrationCollection the name of the collection for keeping applied migration information.
$templateFile

Méthodes publiques

Méthode Description
beforeAction ( Action $action ) : boolean This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
options ( $actionID )

Méthodes protégées

Méthode Description
addMigrationHistory ( $version )
createMigration ( string $class ) : Migration Creates a new migration instance.
ensureBaseMigrationHistory ( ) Ensures migration history contains at least base migration entry.
getMigrationHistory ( $limit )
removeMigrationHistory ( $version )

Method Details

addMigrationHistory() protected méthode

protected addMigrationHistory ( $version )

beforeAction() public méthode

This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
Résultat boolean whether the action should continue to be executed.

createMigration() protected méthode

Creates a new migration instance.
protected createMigration ( string $class ) : Migration
$class string the migration class name
Résultat yii\mongodb\Migration the migration instance

ensureBaseMigrationHistory() protected méthode

Ensures migration history contains at least base migration entry.

getMigrationHistory() protected méthode

protected getMigrationHistory ( $limit )

options() public méthode

public options ( $actionID )

removeMigrationHistory() protected méthode

protected removeMigrationHistory ( $version )

Property Details

$db public_oe property

the DB connection object or the application component ID of the DB connection.
public $db

$migrationCollection public_oe property

the name of the collection for keeping applied migration information.
public $migrationCollection

$templateFile public_oe property

public $templateFile