Skip to content

Commit ab7978d

Browse files
committed
Update m141023_141535_create_user_visit_log.php
1 parent ade6129 commit ab7978d

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

migrations/m141023_141535_create_user_visit_log.php

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

15-
$this->createTable(Yii::$app->getModule('user-management')->user_visit_log_table, array(
16-
'id' => 'pk',
17-
'token' => 'string not null',
18-
'ip' => 'varchar(15) not null',
19-
'language' => 'char(2) not null',
20-
'browser_and_os' => 'string not null',
21-
'user_id' => 'int',
22-
'visit_time' => 'int not null',
23-
0 => 'FOREIGN KEY (user_id) REFERENCES '.Yii::$app->getModule('user-management')->user_table.' (id) ON DELETE SET NULL ON UPDATE CASCADE',
24-
), $tableOptions);
25-
26-
15+
// Check if user_visit_log_table Table exist
16+
$table_name = \Yii::$app->getModule('user-management')->user_visit_log_table;
17+
if (\Yii::$app->db->schema->getTableSchema($table_name) === null)
18+
{
19+
// Create user_visit_log_table table
20+
$this->createTable($table_name, array(
21+
'id' => 'pk',
22+
'token' => 'string not null',
23+
'ip' => 'varchar(15) not null',
24+
'language' => 'char(2) not null',
25+
'browser_and_os' => 'string not null',
26+
'user_id' => 'int',
27+
'visit_time' => 'int not null',
28+
0 => 'FOREIGN KEY (user_id) REFERENCES '.Yii::$app->getModule('user-management')->user_table.' (id) ON DELETE SET NULL ON UPDATE CASCADE',
29+
), $tableOptions);
30+
}
2731
}
2832

2933
public function safeDown()

0 commit comments

Comments
 (0)