yii2-test-1/console/migrations/m230503_151339_create_profile_table.php

34 lines
768 B
PHP
Raw Permalink Normal View History

2023-05-06 20:40:02 +03:00
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%profile}}`.
*/
class m230503_151339_create_profile_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%profile}}', [
'id' => $this->primaryKey(),
'user_id' => $this->integer(),
'created_at' => $this->timestamp(),
'image' => $this->string(),
'activity' => $this->tinyInteger()
]);
$this->addForeignKey('user_foreign', 'profile', 'user_id', 'user', 'id');
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('user_foreign', 'profile');
$this->dropTable('{{%profile}}');
}
}