<?php

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

/**
 * The plan's rank, frozen with the rest of the snapshot.
 *
 * Which direction a later plan change goes must not be read from prices: a
 * grandfathered plan can cost less than a smaller plan does today, and
 * comparing those would charge a customer immediately for losing resources.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('subscriptions', function (Blueprint $table) {
            $table->unsignedTinyInteger('tier')->default(0)->after('plan');
        });
    }

    public function down(): void
    {
        Schema::table('subscriptions', function (Blueprint $table) {
            $table->dropColumn('tier');
        });
    }
};
