<?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('project_competitors',function(Blueprint$t){$t->id();$t->ulid('ulid')->unique();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->string('name',150);$t->string('domain',253);$t->string('normalized_domain',253);$t->string('status',20)->default('active')->index();$t->timestamp('archived_at')->nullable()->index();$t->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();$t->timestamps();$t->unique(['project_id','normalized_domain'],'project_competitors_domain_unique');$t->index(['project_id','status','archived_at'],'project_competitors_active_index');});Schema::create('competitor_audits',function(Blueprint$t){$t->id();$t->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->foreignId('competitor_id')->nullable()->constrained('project_competitors')->nullOnDelete();$t->string('action',40)->index();$t->uuid('correlation_id')->index();$t->json('before')->nullable();$t->json('after')->nullable();$t->timestamps();});}public function down():void{Schema::dropIfExists('competitor_audits');Schema::dropIfExists('project_competitors');}};
