<?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()
    {
        // 添加索引到 ufutx_activity_orders 表的 user_id 字段
        Schema::table('activity_orders', function (Blueprint $table) {
            $table->index('user_id');
        });

        // 添加索引到 ufutx_lotto_codes 表的 user_id 和 code 字段
        Schema::table('lotto_codes', function (Blueprint $table) {
            $table->index('user_id');
            $table->index('code');
        });

        // 添加索引到 ufutx_lottery_win_members 表的 code 字段
        Schema::table('lottery_win_members', function (Blueprint $table) {
            $table->index('code');
        });

        // 添加索引到 ufutx_agent_shops 表的 shop_id 和 is_show 字段
        Schema::table('agent_shops', function (Blueprint $table) {
            $table->index('shop_id');
            $table->index('is_show');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // 移除索引
        Schema::table('activity_orders', function (Blueprint $table) {
            $table->dropIndex(['user_id']);
        });

        Schema::table('lotto_codes', function (Blueprint $table) {
            $table->dropIndex(['user_id', 'code']);
        });

        Schema::table('lottery_win_members', function (Blueprint $table) {
            $table->dropIndex(['code']);
        });

        Schema::table('agent_shops', function (Blueprint $table) {
            $table->dropIndex(['shop_id', 'is_show']);
        });
    }
};
