<?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
    {
        Schema::table('t_stock_opnames', function (Blueprint $table) {
            if (!Schema::hasColumn('t_stock_opnames', 'editing_by')) {
                $table->integer('editing_by')->nullable()->after('updated_by');
            }
            if (!Schema::hasColumn('t_stock_opnames', 'editing_at')) {
                $table->timestamp('editing_at')->nullable()->after('editing_by');
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('t_stock_opnames', function (Blueprint $table) {
            if (Schema::hasColumn('t_stock_opnames', 'editing_by')) {
                $table->dropColumn('editing_by');
            }
            if (Schema::hasColumn('t_stock_opnames', 'editing_at')) {
                $table->dropColumn('editing_at');
            }
        });
    }
};
