resource/database/migrations/slave_sites-2 2.php
2026-01-21 19:53:48 +08:00

30 lines
839 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('slave_sites', function (Blueprint $table) {
// 1. 先把那个重名的唯一索引给我卸了!
$table->dropUnique(['sCode']);
});
Schema::table('slave_sites', function (Blueprint $table) {
// 2. 重新冲锋:修改长度并重新建立唯一约束
$table->string('sCode', 100)->unique()->change();
});
}
public function down(): void
{
Schema::table('slave_sites', function (Blueprint $table) {
// 撤退逻辑:按需写
$table->string('sCode', 255)->change();
});
}
};