<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('stores', function (Blueprint $table) {
            // Make region_id nullable (frontend may not always provide it)
            $table->foreignId('region_id')->nullable()->change();

            // Add fields that frontend form expects
            $table->string('contact', 50)->nullable()->after('phone')->comment('联系人');
            $table->unsignedSmallInteger('capacity')->default(0)->after('contact')->comment('床位数');
            $table->string('description', 500)->nullable()->after('capacity')->comment('备注');
        });
    }

    public function down(): void
    {
        Schema::table('stores', function (Blueprint $table) {
            $table->dropColumn(['contact', 'capacity', 'description']);
        });
    }
};
