<?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
    {
        if (Schema::hasColumn('customers', 'ob_no')) {
            Schema::table('customers', function (Blueprint $table) {
                $table->dropColumn('ob_no');
            });
        }

        if (Schema::hasColumn('print_jobs', 'ob_no')) {
            Schema::table('print_jobs', function (Blueprint $table) {
                $table->dropColumn('ob_no');
            });
        }
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            $table->string('ob_no')->nullable()->after('name');
        });

        Schema::table('print_jobs', function (Blueprint $table) {
            $table->string('ob_no')->nullable()->after('customer_name');
        });
    }
};
