From ff6556c0bac175807f95ff44b9ac42c4fb9a97e5 Mon Sep 17 00:00:00 2001 From: Alessandro Briosi Date: Fri, 13 Apr 2018 15:48:31 +0200 Subject: [PATCH] fix migration to work with SQL Server --- src/User/Migration/m000000_000002_create_profile_table.php | 4 +++- src/User/Migration/m000000_000006_add_two_factor_fields.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/User/Migration/m000000_000002_create_profile_table.php b/src/User/Migration/m000000_000002_create_profile_table.php index 44f0490..aec68f6 100644 --- a/src/User/Migration/m000000_000002_create_profile_table.php +++ b/src/User/Migration/m000000_000002_create_profile_table.php @@ -21,7 +21,7 @@ class m000000_000002_create_profile_table extends Migration $this->createTable( '{{%profile}}', [ - 'user_id' => $this->primaryKey(), + 'user_id' => $this->integer()->notNull(), 'name' => $this->string(255), 'public_email' => $this->string(255), 'gravatar_email' => $this->string(255), @@ -34,6 +34,8 @@ class m000000_000002_create_profile_table extends Migration MigrationHelper::resolveTableOptions($this->db->driverName) ); + $this->addPrimaryKey('{{%profile_pk}}','{{%profile}}','user_id'); + $restrict = MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT'; $this->addForeignKey('fk_profile_user', '{{%profile}}', 'user_id', '{{%user}}', 'id', 'CASCADE', $restrict); diff --git a/src/User/Migration/m000000_000006_add_two_factor_fields.php b/src/User/Migration/m000000_000006_add_two_factor_fields.php index b9ec7ed..2da4dc7 100644 --- a/src/User/Migration/m000000_000006_add_two_factor_fields.php +++ b/src/User/Migration/m000000_000006_add_two_factor_fields.php @@ -18,7 +18,7 @@ class m000000_000006_add_two_factor_fields extends Migration public function safeUp() { $this->addColumn('{{%user}}', 'auth_tf_key', $this->string(16)); - $this->addColumn('{{%user}}', 'auth_tf_enabled', $this->boolean()->defaultValue(false)); + $this->addColumn('{{%user}}', 'auth_tf_enabled', $this->boolean()->defaultValue(0)); } public function safeDown()