m180202_053527_create_customer_table.php 1.83 KB
<?php

use yii\db\Migration;

/**
 * Handles the creation of table `customer`.
 */
class m180202_053527_create_customer_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        $this->createTable(
            'customer',
            [
                'id'                   => $this->primaryKey(),
                'username'             => $this->string()
                                               ->notNull()
                                               ->unique(),
                'auth_key'             => $this->string(32)
                                               ->notNull(),
                'password_hash'        => $this->string()
                                               ->notNull(),
                'password_reset_token' => $this->string()
                                               ->unique(),
                'email'                => $this->string()
                                               ->unique(),
                
                'status'     => $this->smallInteger()
                                     ->notNull()
                                     ->defaultValue(10),
                'created_at' => $this->integer()
                                     ->notNull(),
                'updated_at' => $this->integer()
                                     ->notNull(),
                'name'       => $this->string(),
                'phone'      => $this->string(),
                'gender'     => $this->smallInteger(1),
                'birthday'   => $this->integer(),
                'city'       => $this->string(),
                'address'    => $this->string(),
                'social_id'  => $this->string(),
            ]
        );
    }
    
    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        $this->dropTable('customer');
    }
}