<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
    // Drop the existing foreign key
    Schema::table('internet_payments', function (Blueprint $table) {
        $table->dropForeign(['station_id']);
        
        // Re-add with cascade
        $table->foreign('station_id')
              ->references('station_id')
              ->on('stations')
              ->onDelete('cascade');
    });
    
    // Also handle employee_station table
    Schema::table('employee_station', function (Blueprint $table) {
        $table->dropForeign(['station_id']);
        
        $table->foreign('station_id')
              ->references('station_id')
              ->on('stations')
              ->onDelete('cascade');
    });
}

public function down()
{
    Schema::table('internet_payments', function (Blueprint $table) {
        $table->dropForeign(['station_id']);
        $table->foreign('station_id')->references('station_id')->on('stations');
    });
}
};
