reports fix
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m240131_080048_add_user_id_column_at_reports_table
|
||||
*/
|
||||
class m240131_080048_add_user_id_column_at_reports_table extends Migration
|
||||
{
|
||||
private const TABLE_NAME = "reports";
|
||||
|
||||
private const COLUMN_NAME = "user_id";
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn(self::TABLE_NAME, self::COLUMN_NAME, $this->integer(11)->after("status"));
|
||||
$this->addForeignKey('fk_reports_user', self::TABLE_NAME, self::COLUMN_NAME, 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('fk_reports_user', self::TABLE_NAME);
|
||||
$this->dropColumn(self::TABLE_NAME, self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m240131_080048_add_user_id_column_at_reports_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the dropping of table `{{%fk_reports_user_card_id_at_reports}}`.
|
||||
*/
|
||||
class m240131_132201_drop_fk_reports_user_card_id_at_reports_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropForeignKey("fk-reports-user_card_id", "reports");
|
||||
$this->dropIndex("idx-reports-user_card_id", "reports");
|
||||
$this->alterColumn("reports", "user_card_id", $this->integer(11));
|
||||
$this->alterColumn("reports", "status", $this->integer(1)->defaultValue(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user