<?php

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

return new class extends Migration {
    public function up()
    {
        if (Schema::hasTable('egame_items') && !Schema::hasColumn('egame_items', 'ingress')) {
            Schema::table('egame_items', function (Blueprint $table) {
                $table->string('ingress', 16)->default('3')->after('name')->comment('1电脑 2手机 3通用');
            });
        }
    }

    public function down()
    {
        if (Schema::hasTable('egame_items') && Schema::hasColumn('egame_items', 'ingress')) {
            Schema::table('egame_items', function (Blueprint $table) {
                $table->dropColumn('ingress');
            });
        }
    }
};
