<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('wisebee_consultations', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('wisebee_user_id');
            $table->index('wisebee_created_by_id');
            $table->index('item_id');
            $table->index('status');
            $table->index('public_key');
            $table->index('consultation_date');
            $table->index('time_from');
            $table->index('time_to');
        });

        Schema::table('wisebee_documents', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('consultation_id');
            $table->index('documentable_id');
        });

        Schema::table('wisebee_members', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('member_id');
        });

        Schema::table('wisebee_notes', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('member_note_id');
        });

        Schema::table('wisebee_users', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('admin_user_id');
        });

        Schema::table('wisebee_participants', function (Blueprint $table) {
            $table->index('wisebee_id');
            $table->index('wisebee_consultation_id');
            $table->index('status');
            $table->index('type');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('wisebee_consultations', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['wisebee_user_id']);
            $table->dropIndex(['wisebee_created_by_id']);
            $table->dropIndex(['item_id']);
            $table->dropIndex(['status']);
            $table->dropIndex(['public_key']);
            $table->dropIndex(['consultation_date']);
            $table->dropIndex(['time_from']);
            $table->dropIndex(['time_to']);
        });

        Schema::table('wisebee_documents', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['consultation_id']);
            $table->dropIndex(['documentable_id']);
        });

        Schema::table('wisebee_members', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['member_id']);
        });

        Schema::table('wisebee_notes', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['member_note_id']);
        });

        Schema::table('wisebee_users', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['admin_user_id']);
        });

        Schema::table('wisebee_participants', function (Blueprint $table) {
            $table->dropIndex(['wisebee_id']);
            $table->dropIndex(['wisebee_consultation_id']);
            $table->dropIndex(['status']);
            $table->dropIndex(['type']);
        });
    }
};
