<?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::create('organizations',function(Blueprint $t){$t->id();$t->foreignId('parent_id')->nullable()->constrained('organizations')->nullOnDelete();$t->string('type',50);$t->string('name');$t->string('acronym',80)->nullable();$t->string('slug')->unique();$t->string('logo_path')->nullable();$t->string('website')->nullable();$t->string('theme_color',20)->default('#0b6b45');$t->string('email')->nullable();$t->string('phone',40)->nullable();$t->text('address')->nullable();$t->date('period_start')->nullable();$t->date('period_end')->nullable();$t->boolean('is_active')->default(true);$t->timestamps();});
Schema::create('users',function(Blueprint $t){$t->id();$t->foreignId('organization_id')->nullable()->constrained()->nullOnDelete();$t->string('name');$t->string('email')->unique();$t->timestamp('email_verified_at')->nullable();$t->string('password');$t->string('role',40)->default('admin_unit');$t->boolean('is_active')->default(true);$t->rememberToken();$t->timestamps();});
Schema::create('password_reset_tokens',function(Blueprint $t){$t->string('email')->primary();$t->string('token');$t->timestamp('created_at')->nullable();});
Schema::create('sessions',function(Blueprint $t){$t->string('id')->primary();$t->foreignId('user_id')->nullable()->index();$t->string('ip_address',45)->nullable();$t->text('user_agent')->nullable();$t->longText('payload');$t->integer('last_activity')->index();});
} public function down(): void {Schema::dropIfExists('sessions');Schema::dropIfExists('password_reset_tokens');Schema::dropIfExists('users');Schema::dropIfExists('organizations');}};
