<?php

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

/**
 * Class m231024_062121_add_column_producer_options_exports
 */
class m231024_062121_add_column_producer_options_exports extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->addColumn('producer', 'option_distribution_export_orders_pdf', Schema::TYPE_BOOLEAN.' DEFAULT 1');
        $this->addColumn('producer', 'option_distribution_export_orders_grid_pdf', Schema::TYPE_BOOLEAN);
        $this->addColumn('producer', 'option_distribution_export_orders1_csv', Schema::TYPE_BOOLEAN.' DEFAULT 1');
        $this->addColumn('producer', 'option_distribution_export_orders2_csv', Schema::TYPE_BOOLEAN);
        $this->addColumn('producer', 'option_distribution_export_total_products_csv', Schema::TYPE_BOOLEAN);
        $this->addColumn('producer', 'option_distribution_export_shopping_cart_labels_pdf', Schema::TYPE_BOOLEAN);

        $this->execute("UPDATE producer SET option_distribution_export_orders_grid_pdf = 1 WHERE option_display_export_grid = 1");
        $this->dropColumn('producer', 'option_display_export_grid');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropColumn('producer', 'option_distribution_export_shopping_cart_labels_pdf');
        $this->dropColumn('producer', 'option_distribution_export_total_products_csv');
        $this->dropColumn('producer', 'option_distribution_export_orders1_csv');
        $this->dropColumn('producer', 'option_distribution_export_orders2_csv');
        $this->dropColumn('producer', 'option_distribution_export_orders_pdf');
        $this->dropColumn('producer', 'option_distribution_export_orders_grid_pdf');
    }
}
