<?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('invoices', function (Blueprint $table) {
            $table->unsignedInteger('print_count')->default(0)->after('metadata');
            $table->timestamp('last_printed_at')->nullable()->after('print_count');
        });

        Schema::table('payments', function (Blueprint $table) {
            $table->unsignedInteger('print_count')->default(0)->after('metadata');
            $table->timestamp('last_printed_at')->nullable()->after('print_count');
        });
    }

    public function down(): void
    {
        Schema::table('invoices', function (Blueprint $table) {
            $table->dropColumn(['print_count', 'last_printed_at']);
        });

        Schema::table('payments', function (Blueprint $table) {
            $table->dropColumn(['print_count', 'last_printed_at']);
        });
    }
};
