m130524_201442_init.php 915 Bytes
Newer Older
1 2
<?php

Suralc committed
3 4
use yii\db\Schema;

5 6 7 8
class m130524_201442_init extends \yii\db\Migration
{
	public function up()
	{
9 10 11 12
		$tableOptions = null;
		if ($this->db->driverName === 'mysql') {
			$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
		}
13

Alexander Makarov committed
14
		$this->createTable('tbl_user', [
15
			'id' => Schema::TYPE_PK,
16 17 18 19 20 21
			'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 . '(32)',
			'email' => Schema::TYPE_STRING . ' NOT NULL',
			'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
22

23
			'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
24 25
			'create_time' => Schema::TYPE_INTEGER.' NOT NULL',
			'update_time' => Schema::TYPE_INTEGER.' NOT NULL',
Alexander Makarov committed
26
		], $tableOptions);
27 28 29 30 31 32 33
	}

	public function down()
	{
		$this->dropTable('tbl_user');
	}
}