<?php

use yii\db\Migration;
use yii\db\Schema;

/**
 * Class m240604_093627_add_columns_shared_point_sale_created_confirmed_declined
 */
class m240604_093627_add_columns_shared_point_sale_created_confirmed_declined extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->addColumn('shared_point_sale', 'created_at', Schema::TYPE_DATETIME);
        $this->addColumn('shared_point_sale', 'created_by', Schema::TYPE_INTEGER);
        $this->addColumn('shared_point_sale', 'confirmed_at', Schema::TYPE_DATETIME);
        $this->addColumn('shared_point_sale', 'confirmed_by', Schema::TYPE_INTEGER);
        $this->addColumn('shared_point_sale', 'declined_at', Schema::TYPE_DATETIME);
        $this->addColumn('shared_point_sale', 'declined_by', Schema::TYPE_INTEGER);
        $this->addForeignKey('fk_created_by', 'shared_point_sale', 'created_by', 'user', 'id');
        $this->addForeignKey('fk_confirmed_by', 'shared_point_sale', 'confirmed_by', 'user', 'id');
        $this->addForeignKey('fk_declined_by', 'shared_point_sale', 'declined_by', 'user', 'id');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropColumn('shared_point_sale', 'created_at');
        $this->dropColumn('shared_point_sale', 'created_by');
        $this->dropColumn('shared_point_sale', 'confirmed_at');
        $this->dropColumn('shared_point_sale', 'confirmed_by');
        $this->dropColumn('shared_point_sale', 'declined_at');
        $this->dropColumn('shared_point_sale', 'declined_by');
        $this->dropForeignKey('fk_created_by', 'shared_point_sale');
        $this->dropForeignKey('fk_confirmed_by', 'shared_point_sale');
        $this->dropForeignKey('fk_declined_by', 'shared_point_sale');
    }
}
