diff --git a/README.md b/README.md new file mode 100644 index 0000000..aff25f2 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/lib/User/Bootstrap.php b/lib/User/Bootstrap.php index 9dbcadd..3ee7d56 100644 --- a/lib/User/Bootstrap.php +++ b/lib/User/Bootstrap.php @@ -1,5 +1,4 @@ hasModule('user') && $app->getModule('user') instanceof Module) { $map = $this->buildClassMap($app->getModule('user')->classMap); $this->initContainer($app,$map); @@ -49,8 +47,6 @@ class Bootstrap implements BootstrapInterface { $di = Yii::$container; try { - - // events $di->set(Event\FormEvent::class); $di->set(Event\ProfileEvent::class); diff --git a/lib/User/resources/migrations/m000000_000001_create_user_table.php b/lib/User/Migration/m000000_000001_create_user_table.php similarity index 85% rename from lib/User/resources/migrations/m000000_000001_create_user_table.php rename to lib/User/Migration/m000000_000001_create_user_table.php index 3e1fd66..d58cb54 100644 --- a/lib/User/resources/migrations/m000000_000001_create_user_table.php +++ b/lib/User/Migration/m000000_000001_create_user_table.php @@ -1,7 +1,9 @@ $this->integer(), 'blocked_at' => $this->integer(), 'updated_at' => $this->integer()->notNull(), - 'created_at' =>$this->integer()->notNull() + 'created_at' => $this->integer()->notNull() ]); - $this->createIndex('idx_user_username', '{{%user}}', 'username', true); $this->createIndex('idx_user_email', '{{%user}}', 'email', true); } diff --git a/lib/User/resources/migrations/m000000_000002_create_profile_table.php b/lib/User/Migration/m000000_000002_create_profile_table.php similarity index 82% rename from lib/User/resources/migrations/m000000_000002_create_profile_table.php rename to lib/User/Migration/m000000_000002_create_profile_table.php index ee12a17..b8fa244 100644 --- a/lib/User/resources/migrations/m000000_000002_create_profile_table.php +++ b/lib/User/Migration/m000000_000002_create_profile_table.php @@ -1,7 +1,9 @@ $this->string(255), 'gravatar_id' => $this->string(32), 'location' => $this->string(255), - 'website'=> $this->string(255), + 'website' => $this->string(255), 'timezone' => $this->string(40), 'bio' => $this->text() ] diff --git a/lib/User/resources/migrations/m000000_000003_create_social_account_table.php b/lib/User/Migration/m000000_000003_create_social_account_table.php similarity index 90% rename from lib/User/resources/migrations/m000000_000003_create_social_account_table.php rename to lib/User/Migration/m000000_000003_create_social_account_table.php index 58e74dd..e4f5270 100644 --- a/lib/User/resources/migrations/m000000_000003_create_social_account_table.php +++ b/lib/User/Migration/m000000_000003_create_social_account_table.php @@ -1,7 +1,9 @@