<?php

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

class Indexing extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('prefixes', function (Blueprint $table) {
            $table->index('organisation_id');
            $table->index('asn_id');
        });

        Schema::table('prefix_community', function (Blueprint $table) {
            $table->index('prefix_id');
            $table->index('community');
        });

        Schema::table('prefix_geo_ip', function (Blueprint $table) {
            $table->index('prefix_id');
            $table->index('organisation_id');
            $table->index('asn_id');
        });

        Schema::table('prefix_goliath_firewall', function (Blueprint $table) {
            $table->index('prefix_id');
            $table->index('chain_id');
        });

        Schema::table('prefix_goliath_flags', function (Blueprint $table) {
            $table->index('prefix_id');
        });

        Schema::table('prefix_goliath_inline', function (Blueprint $table) {
            $table->index('prefix_id');
        });

        Schema::table('supernets', function (Blueprint $table) {
            $table->index('supernet_id');
            $table->index('subnet_id');
        });

        Schema::table('security_events', function (Blueprint $table) {
            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('prefixes', function (Blueprint $table) {
            $table->dropIndex('organisation_id');
            $table->dropIndex('asn_id');
        });

        Schema::table('prefix_community', function (Blueprint $table) {
            $table->dropIndex('prefix_id');
            $table->dropIndex('community');
        });

        Schema::table('prefix_geo_ip', function (Blueprint $table) {
            $table->dropIndex('prefix_id');
            $table->dropIndex('organisation_id');
            $table->dropIndex('asn_id');
        });

        Schema::table('prefix_goliath_firewall', function (Blueprint $table) {
            $table->dropIndex('prefix_id');
            $table->dropIndex('chain_id');
        });

        Schema::table('prefix_goliath_flags', function (Blueprint $table) {
            $table->dropIndex('prefix_id');
        });

        Schema::table('prefix_goliath_inline', function (Blueprint $table) {
            $table->dropIndex('prefix_id');
        });

        Schema::table('supernets', function (Blueprint $table) {
            $table->dropIndex('supernet_id');
            $table->dropIndex('subnet_id');
        });

        Schema::table('security_events', function (Blueprint $table) {
            $table->dropIndex('user_id');
        });
    }
}
