<?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('subscriptions', function (Blueprint $table) {
            $table->boolean('is_demo')->default(false)->after('status');
            $table->timestamp('cancelled_at')->nullable()->after('grace_ends_at');
            $table->unsignedBigInteger('mrr_iqd')->default(0)->after('expiry_notified'); // normalized monthly value
        });

        Schema::table('tenants', function (Blueprint $table) {
            $table->boolean('is_demo')->default(false)->after('status');
        });
    }

    public function down(): void
    {
        Schema::table('subscriptions', function (Blueprint $table) {
            $table->dropColumn(['is_demo', 'cancelled_at', 'mrr_iqd']);
        });
        Schema::table('tenants', fn (Blueprint $t) => $t->dropColumn('is_demo'));
    }
};
