darkfriend / yii2-data-migrate
RBAC management module for Yii2
Installs: 883
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.0.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-10-20 00:18:17 UTC
README
Yii2 Test Data Migrate Extension
Yii2-Data-Migrate provides a test data control.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist darkfriend/yii2-data-migrate "*"
or add
"darkfriend/yii2-data-migrate": "*"
to the require section of your composer.json.
Usage
Once the extension is installed, simply modify your application configuration as follows:
return [ 'bootstrap' => ['data'], 'modules' => [ 'data' => [ 'class' => 'darkfriend\yii2migrate\ConsoleModule', ], ], ];
After you downloaded and configured Yii2-data-migrate, the last thing you need to do is updating your database schema by applying the migration:
$ php yii data/migrate/up
Migrations are located in the data-migrations
directory.
Migrations
You can create the console migrations for creating/updating RBAC items.
Module setup
To be able create the migrations, you need to add the following code to your console application configuration:
// console.php 'modules' => [ 'data' => [ 'class' => 'darkfriend\yii2migrate\ConsoleModule' ] ]
Creating Migrations
To create a new migration, run the following command:
$ php yii data/migrate/create <name>
The required name
argument gives a brief description about the new migration. For example, if the migration is about creating a new migrate, you may use the name create_migrate_name
and run the following command:
$ php yii data/migrate/create create_migrate_name
Applying Migrations
To upgrade a database to its latest structure, you should apply all available new migrations using the following command:
$ php yii data/migrate
Reverting Migrations
To revert (undo) one or multiple migrations that have been applied before, you can run the following command:
$ php yii data/migrate/down # revert the most recently applied migration $ php yii data/migrate/down 3 # revert the most 3 recently applied migrations
Redoing Migrations
Redoing migrations means first reverting the specified migrations and then applying again. This can be done as follows:
$ php yii data/migrate/redo # redo the last applied migration $ php yii data/migrate/redo 3 # redo the last 3 applied migrations
History Migrations
$ php yii data/migrate/history # show all applied migration