m130524_201442_init.php 1.1 KB
Newer Older
1 2
<?php

Suralc committed
3
use yii\db\Schema;
4
use yii\db\Migration;
Suralc committed
5

6
class m130524_201442_init extends Migration
7
{
8 9 10 11
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
12 13
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
14
        }
15

16
        $this->createTable('{{%user}}', [
17 18 19 20 21 22
            'id' => Schema::TYPE_PK,
            'username' => Schema::TYPE_STRING . ' NOT NULL',
            'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL',
            'password_hash' => Schema::TYPE_STRING . ' NOT NULL',
            'password_reset_token' => Schema::TYPE_STRING,
            'email' => Schema::TYPE_STRING . ' NOT NULL',
23

24 25 26 27 28
            'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
            'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',
            'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL',
        ], $tableOptions);
    }
29

30 31
    public function down()
    {
32
        $this->dropTable('{{%user}}');
33
    }
34
}