<?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')) {
            return;
        }

        Schema::create('egame_items', function (Blueprint $table) {
            $table->id();
            $table->string('item_type', 16)->comment('platform/game');
            $table->string('plat_type', 32)->comment('三方平台代码');
            $table->unsignedTinyInteger('game_type')->default(0)->comment('游戏类型');
            $table->string('game_code', 128)->default('')->comment('三方游戏代码，平台行为空');
            $table->string('name', 128)->default('')->comment('展示名称');
            $table->string('ingress', 16)->default('3')->comment('1电脑 2手机 3通用');
            $table->string('logo', 500)->default('')->comment('平台logo/游戏square图');
            $table->json('logo_langs')->nullable()->comment('游戏多语言square图');
            $table->unsignedTinyInteger('status')->default(1)->comment('1开启 0关闭');
            $table->integer('sort')->default(0)->comment('排序，越大越靠前');
            $table->timestamps();

            $table->unique(['item_type', 'plat_type', 'game_type', 'game_code'], 'uniq_egame_item');
            $table->index(['item_type', 'plat_type', 'game_type', 'status'], 'idx_egame_item_query');
        });
    }

    public function down()
    {
        Schema::dropIfExists('egame_items');
    }
};
