Merged in migration-namespaces (pull request #1)
Make migrations namespaced: move migrations from "@Da/User/resources/migrations/*.php" to "Da\User\Migration\*.php"
This commit is contained in:
40
README.md
Normal file
40
README.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
Migrations
|
||||||
|
==========
|
||||||
|
|
||||||
|
Add the following settings to your console application configuration file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
return [
|
||||||
|
// ...
|
||||||
|
'controllerMap' => [
|
||||||
|
'migrate' => [
|
||||||
|
'class' => \yii\console\controllers\MigrateController::class,
|
||||||
|
'migrationNamespaces' => [
|
||||||
|
'Da\User\Migration',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
// ...
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
This will allow you to run only a single console command:
|
||||||
|
|
||||||
|
```
|
||||||
|
./yii migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
It prevents you from manual tracking of new migrations coming from our extension. What if we would add a new migration class, and you forgot to run appropriate console command to launch them?
|
||||||
|
|
||||||
|
Without namespaced migrations it would be:
|
||||||
|
|
||||||
|
```
|
||||||
|
./yii migrate
|
||||||
|
./yii migrate --migrationPath="@Da/User/resources/migrations"
|
||||||
|
```
|
||||||
|
|
||||||
|
Without namespaced migrations it's just:
|
||||||
|
|
||||||
|
```
|
||||||
|
./yii migrate
|
||||||
|
```
|
||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Da\User;
|
namespace Da\User;
|
||||||
|
|
||||||
use Da\User\Helper\ClassMapHelper;
|
use Da\User\Helper\ClassMapHelper;
|
||||||
@ -21,7 +20,6 @@ class Bootstrap implements BootstrapInterface
|
|||||||
*/
|
*/
|
||||||
public function bootstrap($app)
|
public function bootstrap($app)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($app->hasModule('user') && $app->getModule('user') instanceof Module) {
|
if ($app->hasModule('user') && $app->getModule('user') instanceof Module) {
|
||||||
$map = $this->buildClassMap($app->getModule('user')->classMap);
|
$map = $this->buildClassMap($app->getModule('user')->classMap);
|
||||||
$this->initContainer($app,$map);
|
$this->initContainer($app,$map);
|
||||||
@ -49,8 +47,6 @@ class Bootstrap implements BootstrapInterface
|
|||||||
{
|
{
|
||||||
$di = Yii::$container;
|
$di = Yii::$container;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
// events
|
// events
|
||||||
$di->set(Event\FormEvent::class);
|
$di->set(Event\FormEvent::class);
|
||||||
$di->set(Event\ProfileEvent::class);
|
$di->set(Event\ProfileEvent::class);
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000001_create_user_table extends \yii\db\Migration
|
class m000000_000001_create_user_table extends Migration
|
||||||
{
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
@ -20,7 +22,6 @@ class m000000_000001_create_user_table extends \yii\db\Migration
|
|||||||
'created_at' => $this->integer()->notNull()
|
'created_at' => $this->integer()->notNull()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$this->createIndex('idx_user_username', '{{%user}}', 'username', true);
|
$this->createIndex('idx_user_username', '{{%user}}', 'username', true);
|
||||||
$this->createIndex('idx_user_email', '{{%user}}', 'email', true);
|
$this->createIndex('idx_user_email', '{{%user}}', 'email', true);
|
||||||
}
|
}
|
||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000002_create_profile_table extends \yii\db\Migration
|
class m000000_000002_create_profile_table extends Migration
|
||||||
{
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000003_create_social_account_table extends \yii\db\Migration
|
class m000000_000003_create_social_account_table extends Migration
|
||||||
{
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000004_create_token_table extends \yii\db\Migration
|
class m000000_000004_create_token_table extends Migration
|
||||||
{
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Da\User;
|
namespace Da\User;
|
||||||
|
|
||||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
use Da\User\Contracts\MailChangeStrategyInterface;
|
||||||
|
|||||||
Reference in New Issue
Block a user