<?php

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

/**
 * Package cancellation: effective at end of billing term, irreversible once set.
 * At service_ends_at the data export is delivered and the instance is deprovisioned
 * (both mocked for now). status gains 'cancellation_scheduled'.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('instances', function (Blueprint $table) {
            $table->timestamp('cancel_requested_at')->nullable()->after('status');
            $table->timestamp('service_ends_at')->nullable()->after('cancel_requested_at');
        });
    }

    public function down(): void
    {
        Schema::table('instances', function (Blueprint $table) {
            $table->dropColumn(['cancel_requested_at', 'service_ends_at']);
        });
    }
};
