<?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('shop_expense_categories', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('shop_id');
            $table->string('code')->index();
            $table->string('name');
            $table->text('description')->nullable();
            $table->dateTime('local_db_created_at')->nullable();
            $table->timestamps();

            $table->foreign('shop_id')->references('id')->on('accounts')->onDelete('cascade');
            $table->unique(['shop_id', 'code']);
        });
    }

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