i am in use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { // NOTE: Pivot tables for PPPoE plans and routers are now created in // tenant-specific migrations (database/migrations/tenant). // This root migration is kept for compatibility and is intentionally // a no-op on connections that do not have the tenant tables. if (!Schema::hasTable('pppoe_plans') || !Schema::hasTable('routers')) { // Nothing to do on this connection. return; } if (Schema::hasTable('pppoe_plan_routers')) { return; } Schema::create('pppoe_plan_routers', function (Blueprint $table) { $table->id(); $table->foreignId('plan_id')->constrained('pppoe_plans')->onDelete('cascade'); $table->foreignId('router_id')->constrained('routers')->onDelete('cascade'); $table->enum('sync_status', ['pending', 'synced', 'failed', 'retrying'])->default('pending'); $table->timestamp('last_synced_at')->nullable(); $table->text('sync_error')->nullable(); $table->timestamps(); // Constraints $table->unique(['plan_id', 'router_id'], 'unique_pppoe_plan_router'); // Indexes for performance $table->index('router_id', 'idx_pppoe_plan_routers_router'); $table->index('sync_status', 'idx_pppoe_plan_routers_sync_status'); $table->index(['plan_id', 'router_id'], 'idx_pppoe_plan_routers_plan_router'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('pppoe_plan_routers'); } };