<?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('websites', function (Blueprint $table) {
            $table->foreignId('tier_id')->after('domain')->nullable()->constrained()->cascadeOnDelete();
            $table->dropColumn(['tier', 'tier_fields']);
        });
    }

    public function down(): void
    {
        Schema::table('websites', function (Blueprint $table) {
            $table->dropForeign(['tier_id']);
            $table->dropColumn('tier_id');
            $table->enum('tier', ['basic', 'standard', 'premium'])->default('basic');
            $table->json('tier_fields')->nullable();
        });
    }
};
