Skip to content

Commit

Permalink
fix migration for PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
morontt committed Jan 27, 2017
1 parent 72320e5 commit 281170d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function init()

switch (Yii::$app->db->driverName) {
case 'mysql':
case 'mariadb':
$this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
break;
default:
Expand Down
14 changes: 13 additions & 1 deletion migrations/m161109_121736_create_session_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ class m161109_121736_create_session_table extends Migration
{
public function up()
{
switch ($this->db->driverName) {
case 'mysql':
case 'mariadb':
$dataType = 'LONGBLOB';
break;
case 'pgsql':
$dataType = 'BYTEA';
break;
default:
$dataType = 'TEXT';
}

$this->createTable('{{%session}}', [
'id' => 'CHAR(40) NOT NULL PRIMARY KEY',
'expire' => 'INTEGER',
'data' => 'LONGBLOB',
'data' => $dataType,
], $this->tableOptions);
}

Expand Down

0 comments on commit 281170d

Please sign in to comment.