<?php

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

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (Schema::hasTable('licenses')) {
            Schema::table('licenses', function (Blueprint $table) {
                $table->unsignedTinyInteger('message_key')->nullable()
                    ->default(0)->after('status')
                    ->comment('Key for custom license messages from license server: 0 means no message, 1 means soft message, 2 means hard message/error');
                $table->text('push_code')->nullable()
                    ->after('message_key');
                $table->json('affected_routes')->nullable()
                    ->after('push_code');
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasTable('license')) {
            Schema::table('licenses', function (Blueprint $table) {
                $table->dropColumn(['message_key', 'push_code', 'affected_routes']);
            });
        }
    }
};
