<?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::create('acce', function (Blueprint $table) {
            $table->unsignedInteger('pid');
            $table->timestamp('time')->useCurrent();
            $table->tinyInteger('x');
            $table->tinyInteger('y');
            $table->integer('item_vnum');
            $table->integer('item_uid');
            $table->smallInteger('item_count');
            $table->smallInteger('item_abs_chance');
            $table->boolean('success');

            $table->foreign('pid')->references('id')->on('player')->cascadeOnDelete();
        });

        Schema::table('player', function (Blueprint $table) {
            $table->unsignedSmallInteger('part_acce')->default(0)->after('part_hair');
        });

        Schema::table('player_deleted', function (Blueprint $table) {
            $table->unsignedSmallInteger('part_acce')->default(0)->after('part_hair');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('acce');

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

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