<?php

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

/**
 * Class m230913_071815_alter_table_credit_history_rename_payment
 */
class m230913_071815_alter_table_credit_history_rename_payment extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->renameTable('credit_history', 'payment');
        $this->addColumn('payment', 'id_invoice', Schema::TYPE_INTEGER);
        $this->alterColumn('payment', 'id_user', Schema::TYPE_INTEGER.' DEFAULT NULL');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->renameTable('payment', 'credit_history');
    }
}
