<?php

use yii\db\Migration;

class m161226_102102_user_data extends Migration
{
    public function up()
    {
        $this->createTable('user_data', [
            'id' => $this->primaryKey(),
            'user_id' => $this->integer(),
            'name' => $this->string(255),
            'surname' => $this->string(255),
            'patronymic' => $this->string(255),
            'phone' => $this->string(255),
            'email' => $this->string(255),
            'inn' => $this->string(255),
        ]);
        
        $this->addForeignKey('user_data_fk', 'user_data', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
    }

    public function down()
    {
        $this->dropForeignKey('user_data_fk', 'user_data');
        $this->dropTable('user_data');
    }
}
