Skip to content

Commit 281170d

Browse files
committed
fix migration for PostgreSQL
1 parent 72320e5 commit 281170d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

components/Migration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function init()
2525

2626
switch (Yii::$app->db->driverName) {
2727
case 'mysql':
28+
case 'mariadb':
2829
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
2930
break;
3031
default:

migrations/m161109_121736_create_session_table.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@ class m161109_121736_create_session_table extends Migration
99
{
1010
public function up()
1111
{
12+
switch ($this->db->driverName) {
13+
case 'mysql':
14+
case 'mariadb':
15+
$dataType = 'LONGBLOB';
16+
break;
17+
case 'pgsql':
18+
$dataType = 'BYTEA';
19+
break;
20+
default:
21+
$dataType = 'TEXT';
22+
}
23+
1224
$this->createTable('{{%session}}', [
1325
'id' => 'CHAR(40) NOT NULL PRIMARY KEY',
1426
'expire' => 'INTEGER',
15-
'data' => 'LONGBLOB',
27+
'data' => $dataType,
1628
], $this->tableOptions);
1729
}
1830

0 commit comments

Comments
 (0)