id(); $table->foreignId('tenant_id')->constrained()->restrictOnDelete(); $table->foreignId('created_by')->constrained('users')->restrictOnDelete(); $table->unsignedInteger('revision'); $table->string('status')->default('pending'); $table->string('mode'); $table->boolean('enabled'); $table->date('valid_from'); $table->date('valid_until'); $table->text('reason'); $table->timestamp('decided_at')->nullable(); $table->timestamps(); $table->unique(['tenant_id', 'revision']); }); Schema::create('purchase_control_reviews', function (Blueprint $table) { $table->id(); $table->foreignId('tenant_id')->constrained()->restrictOnDelete(); $table->foreignId('purchase_control_policy_id')->constrained()->restrictOnDelete(); $table->foreignId('reviewed_by')->constrained('users')->restrictOnDelete(); $table->string('decision'); $table->text('reason'); $table->timestamp('created_at'); $table->unique(['purchase_control_policy_id', 'reviewed_by']); }); Schema::create('award_cancellations', function (Blueprint $table) { $table->id(); $table->foreignId('tenant_id')->constrained()->restrictOnDelete(); $table->foreignId('purchase_award_id')->unique()->constrained()->restrictOnDelete(); $table->foreignId('purchase_control_policy_id')->constrained()->restrictOnDelete(); $table->foreignId('created_by')->constrained('users')->restrictOnDelete(); $table->foreignId('reviewed_by')->nullable()->constrained('users')->restrictOnDelete(); $table->string('status')->default('pending'); $table->string('basis_hash', 64); $table->text('reason'); $table->text('review_reason')->nullable(); $table->json('snapshot'); $table->timestamp('reviewed_at')->nullable(); $table->timestamps(); }); Schema::create('purchase_revisions', function (Blueprint $table) { $table->id(); $table->foreignId('tenant_id')->constrained()->restrictOnDelete(); $table->foreignId('award_cancellation_id')->unique()->constrained()->restrictOnDelete(); $table->foreignId('source_requisition_id')->constrained('requisitions')->restrictOnDelete(); $table->foreignId('requisition_id')->unique()->constrained()->restrictOnDelete(); $table->foreignId('created_by')->constrained('users')->restrictOnDelete(); $table->timestamp('created_at'); }); } public function down(): void { throw new LogicException('Preservar políticas, cancelamentos e ligações de revisão.'); } };