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
|
||||
|
||||
namespace Da\User;
|
||||
|
||||
use Da\User\Helper\ClassMapHelper;
|
||||
@ -21,7 +20,6 @@ class Bootstrap implements BootstrapInterface
|
||||
*/
|
||||
public function bootstrap($app)
|
||||
{
|
||||
|
||||
if ($app->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);
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
<?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()
|
||||
{
|
||||
@ -17,10 +19,9 @@ class m000000_000001_create_user_table extends \yii\db\Migration
|
||||
'confirmed_at' => $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);
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
<?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()
|
||||
{
|
||||
@ -14,7 +16,7 @@ class m000000_000002_create_profile_table extends \yii\db\Migration
|
||||
'gravatar_email' => $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()
|
||||
]
|
||||
@ -1,7 +1,9 @@
|
||||
<?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()
|
||||
{
|
||||
@ -1,7 +1,9 @@
|
||||
<?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()
|
||||
{
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User;
|
||||
|
||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
||||
|
||||
Reference in New Issue
Block a user