diff --git a/migrations/m140209_132017_init.php b/migrations/m140209_132017_init.php index 82add0599..9a10a8621 100644 --- a/migrations/m140209_132017_init.php +++ b/migrations/m140209_132017_init.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; /** * @author Dmitry Erofeev createTable('{{%user}}', [ - 'id' => Schema::TYPE_PK, - 'username' => Schema::TYPE_STRING . '(25) NOT NULL', - 'email' => Schema::TYPE_STRING . '(255) NOT NULL', - 'password_hash' => Schema::TYPE_STRING . '(60) NOT NULL', - 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', - 'confirmation_token' => Schema::TYPE_STRING . '(32) NULL', - 'confirmation_sent_at' => Schema::TYPE_INTEGER. ' NULL', - 'confirmed_at' => Schema::TYPE_INTEGER. ' NULL', - 'unconfirmed_email' => Schema::TYPE_STRING . '(255) NULL', - 'recovery_token' => Schema::TYPE_STRING . '(32) NULL', - 'recovery_sent_at' => Schema::TYPE_INTEGER. ' NULL', - 'blocked_at' => Schema::TYPE_INTEGER. ' NULL', - 'registered_from' => Schema::TYPE_INTEGER. ' NULL', - 'logged_in_from' => Schema::TYPE_INTEGER. ' NULL', - 'logged_in_at' => Schema::TYPE_INTEGER. ' NULL', - 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', - 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL', + 'id' => $this->primaryKey(), + 'username' => $this->string(25)->notNull(), + 'email' => $this->string(255)->notNull(), + 'password_hash' => $this->string(60)->notNull(), + 'auth_key' => $this->string(32)->notNull(), + 'confirmation_token' => $this->string(32)->null(), + 'confirmation_sent_at' => $this->integer()->null(), + 'confirmed_at' => $this->integer()->null(), + 'unconfirmed_email' => $this->string(255)->null(), + 'recovery_token' => $this->string(32)->null(), + 'recovery_sent_at' => $this->integer()->null(), + 'blocked_at' => $this->integer()->null(), + 'registered_from' => $this->integer()->null(), + 'logged_in_from' => $this->integer()->null(), + 'logged_in_at' => $this->integer()->null(), + 'created_at' => $this->integer()->notNull(), + 'updated_at' => $this->integer()->notNull(), ], $this->tableOptions); $this->createIndex('{{%user_unique_username}}', '{{%user}}', 'username', true); @@ -45,14 +44,14 @@ public function up() $this->createIndex('{{%user_recovery}}', '{{%user}}', 'id, recovery_token', true); $this->createTable('{{%profile}}', [ - 'user_id' => Schema::TYPE_INTEGER . ' PRIMARY KEY', - 'name' => Schema::TYPE_STRING . '(255) NULL', - 'public_email' => Schema::TYPE_STRING . '(255) NULL', - 'gravatar_email' => Schema::TYPE_STRING . '(255) NULL', - 'gravatar_id' => Schema::TYPE_STRING . '(32) NULL', - 'location' => Schema::TYPE_STRING . '(255) NULL', - 'website' => Schema::TYPE_STRING . '(255) NULL', - 'bio' => Schema::TYPE_TEXT. ' NULL', + 'user_id' => $this->primaryKey(), + 'name' => $this->string(255)->null(), + 'public_email' => $this->string(255)->null(), + 'gravatar_email' => $this->string(255)->null(), + 'gravatar_id' => $this->string(32)->null(), + 'location' => $this->string(255)->null(), + 'website' => $this->string(255)->null(), + 'bio' => $this->text()->null(), ], $this->tableOptions); $this->addForeignKey('{{%fk_user_profile}}', '{{%profile}}', 'user_id', '{{%user}}', 'id', $this->cascade, $this->restrict); diff --git a/migrations/m140403_174025_create_account_table.php b/migrations/m140403_174025_create_account_table.php index cdc6130c6..d894be023 100644 --- a/migrations/m140403_174025_create_account_table.php +++ b/migrations/m140403_174025_create_account_table.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; /** * @author Dmitry Erofeev createTable('{{%account}}', [ - 'id' => Schema::TYPE_PK, - 'user_id' => Schema::TYPE_INTEGER. ' NULL', - 'provider' => Schema::TYPE_STRING . ' NOT NULL', - 'client_id' => Schema::TYPE_STRING . ' NOT NULL', - 'properties' => Schema::TYPE_TEXT . ' NULL', + 'id' => $this->primaryKey(), + 'user_id' => $this->integer()->null(), + 'provider' => $this->string()->notNull(), + 'client_id' => $this->string()->notNull(), + 'properties' => $this->text()->null(), ], $this->tableOptions); $this->createIndex('{{%account_unique}}', '{{%account}}', ['provider', 'client_id'], true); diff --git a/migrations/m140504_113157_update_tables.php b/migrations/m140504_113157_update_tables.php index b93a346ba..89c05cfa7 100644 --- a/migrations/m140504_113157_update_tables.php +++ b/migrations/m140504_113157_update_tables.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; /** * @author Dmitry Erofeev @@ -29,7 +28,7 @@ public function up() $this->dropColumn('{{%user}}', 'logged_in_from'); $this->dropColumn('{{%user}}', 'logged_in_at'); $this->renameColumn('{{%user}}', 'registered_from', 'registration_ip'); - $this->addColumn('{{%user}}', 'flags', Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0'); + $this->addColumn('{{%user}}', 'flags', $this->integer()->notNull()->defaultValue(0)); // account table $this->renameColumn('{{%account}}', 'properties', 'data'); @@ -43,16 +42,16 @@ public function down() // user table if ($this->dbType == 'sqlsrv') { // this is needed because we need to drop the default constraint first - $this->dropColumnConstraints('{{%user}}','flags'); + $this->dropColumnConstraints('{{%user}}', 'flags'); } $this->dropColumn('{{%user}}', 'flags'); $this->renameColumn('{{%user}}', 'registration_ip', 'registered_from'); - $this->addColumn('{{%user}}', 'logged_in_at', Schema::TYPE_INTEGER); - $this->addColumn('{{%user}}', 'logged_in_from', Schema::TYPE_INTEGER); - $this->addColumn('{{%user}}', 'recovery_sent_at', Schema::TYPE_INTEGER); - $this->addColumn('{{%user}}', 'recovery_token', Schema::TYPE_STRING . '(32)'); - $this->addColumn('{{%user}}', 'confirmation_sent_at', Schema::TYPE_INTEGER); - $this->addColumn('{{%user}}', 'confirmation_token', Schema::TYPE_STRING . '(32)'); + $this->addColumn('{{%user}}', 'logged_in_at', $this->integer()); + $this->addColumn('{{%user}}', 'logged_in_from', $this->integer()); + $this->addColumn('{{%user}}', 'recovery_sent_at', $this->integer()); + $this->addColumn('{{%user}}', 'recovery_token', $this->string(32)); + $this->addColumn('{{%user}}', 'confirmation_sent_at', $this->integer()); + $this->addColumn('{{%user}}', 'confirmation_token', $this->string(32)); $this->createIndex('{{%user_confirmation}}', '{{%user}}', 'id, confirmation_token', true); $this->createIndex('{{%user_recovery}', '{{%user}}', 'id, recovery_token', true); } diff --git a/migrations/m140504_130429_create_token_table.php b/migrations/m140504_130429_create_token_table.php index 65badd472..fc3f23eaa 100644 --- a/migrations/m140504_130429_create_token_table.php +++ b/migrations/m140504_130429_create_token_table.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; /** * @author Dmitry Erofeev @@ -20,10 +19,10 @@ class m140504_130429_create_token_table extends Migration public function up() { $this->createTable('{{%token}}', [ - 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', - 'code' => Schema::TYPE_STRING . '(32) NOT NULL', - 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', - 'type' => Schema::TYPE_SMALLINT . ' NOT NULL', + 'user_id' => $this->integer()->notNull(), + 'code' => $this->string(32)->notNull(), + 'created_at' => $this->integer()->notNull(), + 'type' => $this->smallInteger()->notNull(), ], $this->tableOptions); $this->createIndex('{{%token_unique}}', '{{%token}}', ['user_id', 'code', 'type'], true); diff --git a/migrations/m140830_171933_fix_ip_field.php b/migrations/m140830_171933_fix_ip_field.php index 3ff71ae4c..a67884e90 100644 --- a/migrations/m140830_171933_fix_ip_field.php +++ b/migrations/m140830_171933_fix_ip_field.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; /** * @author Dmitry Erofeev @@ -19,11 +18,11 @@ class m140830_171933_fix_ip_field extends Migration { public function up() { - $this->alterColumn('{{%user}}', 'registration_ip', Schema::TYPE_BIGINT. ' NULL'); + $this->alterColumn('{{%user}}', 'registration_ip', $this->bigInteger()->null()); } public function down() { - $this->alterColumn('{{%user}}', 'registration_ip', Schema::TYPE_INTEGER. ' NULL'); + $this->alterColumn('{{%user}}', 'registration_ip', $this->integer()->null()); } } diff --git a/migrations/m141222_110026_update_ip_field.php b/migrations/m141222_110026_update_ip_field.php index 3a8003589..9ea0c47d1 100644 --- a/migrations/m141222_110026_update_ip_field.php +++ b/migrations/m141222_110026_update_ip_field.php @@ -11,7 +11,6 @@ use dektrium\user\migrations\Migration; use yii\db\Query; -use yii\db\Schema; class m141222_110026_update_ip_field extends Migration { @@ -21,7 +20,7 @@ public function up() $transaction = Yii::$app->db->beginTransaction(); try { - $this->alterColumn('{{%user}}', 'registration_ip', Schema::TYPE_STRING . '(45) NULL'); + $this->alterColumn('{{%user}}', 'registration_ip', $this->string(45)->null()); foreach ($users as $user) { if ($user['ip'] == null) { continue; @@ -44,16 +43,17 @@ public function down() $transaction = Yii::$app->db->beginTransaction(); try { foreach ($users as $user) { - if ($user['ip'] == null) + if ($user['ip'] == null) { continue; + } Yii::$app->db->createCommand()->update('{{%user}}', [ 'registration_ip' => ip2long($user['ip']) ], 'id = ' . $user['id'])->execute(); } if ($this->dbType == 'pgsql') { - $this->alterColumn('{{%user}}', 'registration_ip', Schema::TYPE_BIGINT . ' USING registration_ip::bigint'); + $this->alterColumn('{{%user}}', 'registration_ip', $this->bigInteger() . ' USING registration_ip::bigint'); } else { - $this->alterColumn('{{%user}}', 'registration_ip', Schema::TYPE_BIGINT. ' NULL'); + $this->alterColumn('{{%user}}', 'registration_ip', $this->bigInteger()->null()); } $transaction->commit(); diff --git a/migrations/m141222_135246_alter_username_length.php b/migrations/m141222_135246_alter_username_length.php index 8cb1885e6..90e8acce0 100644 --- a/migrations/m141222_135246_alter_username_length.php +++ b/migrations/m141222_135246_alter_username_length.php @@ -10,16 +10,15 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; class m141222_135246_alter_username_length extends Migration { public function up() { if ($this->dbType == 'sqlsrv') { - $this->dropIndex('{{%user_unique_username}}','{{%user}}'); - } - $this->alterColumn('{{%user}}', 'username', Schema::TYPE_STRING . '(255) NOT NULL'); + $this->dropIndex('{{%user_unique_username}}', '{{%user}}'); + } + $this->alterColumn('{{%user}}', 'username', $this->string(255)->notNull()); if ($this->dbType == 'sqlsrv') { $this->createIndex('{{%user_unique_username}}', '{{%user}}', 'username', true); } @@ -28,9 +27,9 @@ public function up() public function down() { if ($this->dbType == 'sqlsrv') { - $this->dropIndex('{{%user_unique_username}}','{{%user}}'); + $this->dropIndex('{{%user_unique_username}}', '{{%user}}'); } - $this->alterColumn('{{%user}}', 'username', Schema::TYPE_STRING . '(25) NOT NULL'); + $this->alterColumn('{{%user}}', 'username', $this->string(25)->notNull()); if ($this->dbType == 'sqlsrv') { $this->createIndex('{{%user_unique_username}}', '{{%user}}', 'username', true); } diff --git a/migrations/m150614_103145_update_social_account_table.php b/migrations/m150614_103145_update_social_account_table.php index a3725ac1c..82e0a0fa9 100644 --- a/migrations/m150614_103145_update_social_account_table.php +++ b/migrations/m150614_103145_update_social_account_table.php @@ -1,17 +1,16 @@ addColumn('{{%social_account}}', 'code', Schema::TYPE_STRING . '(32) NULL'); - $this->addColumn('{{%social_account}}', 'created_at', Schema::TYPE_INTEGER. ' NULL'); - $this->addColumn('{{%social_account}}', 'email', Schema::TYPE_STRING. ' NULL'); - $this->addColumn('{{%social_account}}', 'username', Schema::TYPE_STRING. ' NULL'); + $this->addColumn('{{%social_account}}', 'code', $this->string(32)->null()); + $this->addColumn('{{%social_account}}', 'created_at', $this->integer()->null()); + $this->addColumn('{{%social_account}}', 'email', $this->string()->null()); + $this->addColumn('{{%social_account}}', 'username', $this->string()->null()); $this->createIndex('{{%account_unique_code}}', '{{%social_account}}', 'code', true); $accounts = (new Query())->from('{{%social_account}}')->select('id')->all(); diff --git a/migrations/m150623_212711_fix_username_notnull.php b/migrations/m150623_212711_fix_username_notnull.php index 5f948387f..46afa50f1 100644 --- a/migrations/m150623_212711_fix_username_notnull.php +++ b/migrations/m150623_212711_fix_username_notnull.php @@ -10,7 +10,6 @@ */ use dektrium\user\migrations\Migration; -use yii\db\Schema; class m150623_212711_fix_username_notnull extends Migration { @@ -20,9 +19,9 @@ public function up() $this->alterColumn('{{%user}}', 'username', 'SET NOT NULL'); } else { if ($this->dbType == 'sqlsrv') { - $this->dropIndex('{{%user_unique_username}}','{{%user}}'); + $this->dropIndex('{{%user_unique_username}}', '{{%user}}'); } - $this->alterColumn('{{%user}}', 'username', Schema::TYPE_STRING . '(255) NOT NULL'); + $this->alterColumn('{{%user}}', 'username', $this->string(255)->notNull()); if ($this->dbType == 'sqlsrv') { $this->createIndex('{{%user_unique_username}}', '{{%user}}', 'username', true); } @@ -31,13 +30,13 @@ public function up() public function down() { - if($this->dbType == "pgsql"){ + if ($this->dbType == "pgsql") { $this->alterColumn('{{%user}}', 'username', 'DROP NOT NULL'); - }else{ + } else { if ($this->dbType == 'sqlsrv') { - $this->dropIndex('{{%user_unique_username}}','{{%user}}'); + $this->dropIndex('{{%user_unique_username}}', '{{%user}}'); } - $this->alterColumn('{{%user}}', 'username', Schema::TYPE_STRING . '(255) NULL'); + $this->alterColumn('{{%user}}', 'username', $this->string(255)->null()); if ($this->dbType == 'sqlsrv') { $this->createIndex('{{%user_unique_username}}', '{{%user}}', 'username', true); } diff --git a/migrations/m151218_234654_add_timezone_to_profile.php b/migrations/m151218_234654_add_timezone_to_profile.php index 41c7ba3d1..a580b9426 100644 --- a/migrations/m151218_234654_add_timezone_to_profile.php +++ b/migrations/m151218_234654_add_timezone_to_profile.php @@ -9,19 +9,17 @@ * file that was distributed with this source code. */ -use yii\db\Schema; use dektrium\user\migrations\Migration; class m151218_234654_add_timezone_to_profile extends Migration { public function up() { - $this->addColumn('{{%profile}}', 'timezone', Schema::TYPE_STRING . '(40) NULL'); + $this->addColumn('{{%profile}}', 'timezone', $this->string(40)->null()); } public function down() { $this->dropcolumn('{{%profile}}', 'timezone'); } - }