<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('sy_offices', function (Blueprint $blueprint) {
            $blueprint->id();
            $blueprint->unsignedBigInteger('fk_site');
            $blueprint->string('officename', 35);
            $blueprint->boolean('visible')->default(true);
            $blueprint->boolean('available')->default(true);
            $blueprint->unsignedBigInteger('fk_usercreator')->nullable();
            $blueprint->timestamp('created_at')->useCurrent();
            $blueprint->unsignedBigInteger('fk_userupdater')->nullable();
            $blueprint->timestamp('updated_at')->useCurrentOnUpdate()->nullable();
            $blueprint->boolean('is_active')->default(true);

            $blueprint->foreign('fk_site')->references('id')->on('sy_sites');
        });

        DB::table('sy_offices')->insert([
            ['officename' => 'TESTING', 'fk_site' => 1, 'fk_usercreator' => 1],
        ]);
    }

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