<?php

use yii\db\Migration;

/**
 * Handles the creation of table `user_data`.
 */
class m170313_092544_create_user_data_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        $this->createTable('user_data', [
            'user_id' => $this->integer()->notNull(),
            'name' => $this->string(),
            'surname' => $this->string(),
            'image' => $this->string(),
            'email' => $this->string(),
            'phone' => $this->string(),
            'created_at' => $this->integer(),
            'updated_at' => $this->integer(),
            'visited_at' => $this->integer(),
        ]);
        
        $this->addForeignKey('user_data_to_user', 'user_data', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
        $this->createIndex('user_id_uk', 'user_data', 'user_id', true);
    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        $this->dropTable('user_data');
    }
}
