<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('pos_sessions', function (Blueprint $table) {
            if (!Schema::hasColumn('pos_sessions', 'updated_by')) {
                $table->unsignedBigInteger('updated_by')->nullable()->after('created_by')->index();
            }
        });

        Schema::table('pos_sessions_archive', function (Blueprint $table) {
            if (!Schema::hasColumn('pos_sessions_archive', 'updated_by')) {
                $table->unsignedBigInteger('updated_by')->nullable()->after('created_by');
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('pos_sessions', function (Blueprint $table) {
            $table->dropColumn('updated_by');
        });

        Schema::table('pos_sessions_archive', function (Blueprint $table) {
            $table->dropColumn('updated_by');
        });
    }
};
