Skip to content

Commit 4e6d34c

Browse files
committed
throw exception if user table already exists in inital migration. See issue #81
1 parent bced9d7 commit 4e6d34c

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

migrations/m140608_173539_create_user_table.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,19 @@ public function safeUp()
1616
// Check if user Table exist
1717
// $tablename = \Yii::$app->db->tablePrefix.'user';
1818
$tablename = \Yii::$app->getModule('user-management')->user_table;
19-
if (\Yii::$app->db->schema->getTableSchema($tablename) === null)
20-
{
21-
// Create user table
22-
$this->createTable($tablename, array(
23-
'id' => 'pk',
24-
'username' => 'string not null',
25-
'auth_key' => 'varchar(32) not null',
26-
'password_hash' => 'string not null',
27-
'confirmation_token' => 'string',
28-
'status' => 'int not null default 1',
29-
'superadmin' => 'smallint default 0',
30-
'created_at' => 'int not null',
31-
'updated_at' => 'int not null',
32-
), $tableOptions);
33-
}
34-
3519

20+
// Create user table
21+
$this->createTable($tablename, array(
22+
'id' => 'pk',
23+
'username' => 'string not null',
24+
'auth_key' => 'varchar(32) not null',
25+
'password_hash' => 'string not null',
26+
'confirmation_token' => 'string',
27+
'status' => 'int not null default 1',
28+
'superadmin' => 'smallint default 0',
29+
'created_at' => 'int not null',
30+
'updated_at' => 'int not null',
31+
), $tableOptions);
3632
}
3733

3834
public function safeDown()

0 commit comments

Comments
 (0)