<?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('shop_codes', function (Blueprint $table) {
            // 创建新的普通索引
            $table->index('code');

            // 删除原来的唯一索引
            $table->dropUnique('ufutx_shop_codes_code_unique');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('shop_codes', function (Blueprint $table) {
            // 撤销操作时，重新创建原来的唯一索引
            $table->unique('code');

            // 删除新的普通索引
            $table->dropIndex('code');
        });
    }
};
