ufutx.dma/database/migrations/2024_05_08_144901_add_table_index.php
2026-03-04 14:42:40 +08:00

64 lines
1.8 KiB
PHP

<?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']);
});
}
};