Skip to content

Commit 45a0c67

Browse files
committed
Update m140608_173539_create_user_table.php
1 parent 5085c03 commit 45a0c67

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

migrations/m140608_173539_create_user_table.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@ public function safeUp()
1313
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
1414
}
1515

16-
$this->createTable(Yii::$app->getModule('user-management')->user_table, array(
17-
'id' => 'pk',
18-
'username' => 'string not null',
19-
'auth_key' => 'varchar(32) not null',
20-
'password_hash' => 'string not null',
21-
'confirmation_token' => 'string',
22-
'status' => 'int not null default 1',
23-
'superadmin' => 'smallint default 0',
24-
'created_at' => 'int not null',
25-
'updated_at' => 'int not null',
26-
), $tableOptions);
16+
// Check if user Table exist
17+
// $tablename = \Yii::$app->db->tablePrefix.'user';
18+
$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+
}
2734

2835

2936
}

0 commit comments

Comments
 (0)