You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

7 years ago
<?php
use yii\db\Migration;
/**
* Handles the creation of table `session`.
*/
class m180126_061916_create_session_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
7 years ago
}
$this->createTable('{{%session}}', [
'id' => $this->char(40)->notNull(),
'expire' => $this->integer(),
'data' => $this->binary(),
3 years ago
'user_id' => $this->bigInteger()
7 years ago
], $tableOptions);
$this->addPrimaryKey('session_pk', 'session', 'id');
$this->createIndex('idx_session_user_id', '{{%session}}', 'user_id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropIndex('idx_session_user_id', '{{%session}}');
$this->dropTable('{{%session}}');
}
}