<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddVirtualOrderCardsPartitionIdx extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('virtual_order_cards', function (Blueprint $table) {
            $table->index(['sim']);
            $table->index(['company_id', 'package_id']);
            $table->index(['service_end_at']);
        });

        Schema::table('virtual_order_renewal_cards', function (Blueprint $table) {
            $table->index(['sim']);
            $table->index(['company_id', 'package_id']);
            $table->index(['service_end_at']);
        });

        Schema::table('virtual_order_renewal_package_cards', function (Blueprint $table) {
            $table->index(['sim']);
            $table->index(['company_id', 'package_id']);
            $table->index(['service_end_at']);
        });

        Schema::table('virtual_order_flows_package_cards', function (Blueprint $table) {
            $table->index(['sim']);
            $table->index(['company_id', 'package_id']);
            $table->index(['service_end_at']);
        });

        Schema::table('virtual_order_upgrade_cards', function (Blueprint $table) {
            $table->index(['sim']);
            $table->index(['company_id', 'package_id']);
            $table->index(['service_end_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('virtual_order_cards', function (Blueprint $table) {
            $table->dropIndex("virtual_order_cards_sim_index");
            $table->dropIndex("virtual_order_cards_company_id_package_id_index");
            $table->dropIndex("virtual_order_cards_service_end_at_index");
        });

        Schema::table('virtual_order_renewal_cards', function (Blueprint $table) {
            $table->dropIndex("virtual_order_renewal_cards_sim_index");
            $table->dropIndex("virtual_order_renewal_cards_company_id_package_id_index");
            $table->dropIndex("virtual_order_renewal_cards_service_end_at_index");
        });

        Schema::table('virtual_order_renewal_package_cards', function (Blueprint $table) {
            $table->dropIndex("virtual_order_renewal_package_cards_sim_index");
            $table->dropIndex("virtual_order_renewal_package_cards_company_id_package_id_index");
            $table->dropIndex("virtual_order_renewal_package_cards_service_end_at_index");
        });

        Schema::table('virtual_order_flows_package_cards', function (Blueprint $table) {
            $table->dropIndex("virtual_order_flows_package_cards_sim_index");
            $table->dropIndex("virtual_order_flows_package_cards_company_id_package_id_index");
            $table->dropIndex("virtual_order_flows_package_cards_service_end_at_index");
        });

        Schema::table('virtual_order_upgrade_cards', function (Blueprint $table) {
            $table->dropIndex("virtual_order_upgrade_cards_sim_index");
            $table->dropIndex("virtual_order_upgrade_cards_company_id_package_id_index");
            $table->dropIndex("virtual_order_upgrade_cards_service_end_at_index");
        });
    }
}
