<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('internet_provider_station', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('station_id');
            $table->unsignedBigInteger('internet_provider_id');
            $table->string('contract_number')->nullable();
            $table->date('start_date')->nullable();
            $table->date('end_date')->nullable();
            $table->string('status')->default('active');
            $table->timestamps();
            
            $table->foreign('station_id')->references('station_id')->on('stations')->onDelete('cascade');
            $table->foreign('internet_provider_id')->references('vendor_id')->on('internet_providers')->onDelete('cascade');
            $table->unique(['station_id', 'internet_provider_id']);
        });
    }
    
    public function down()
    {
        Schema::dropIfExists('internet_provider_station');
    }
};