Carteira 4.3: ligações oportunidade↔carteira propostas e aprovadas na gestão
89 propostas, segundo os critérios aprovados pelo proprietário a partir da simulação do PII, ficam «por decidir» com fonte e evidência. A página «Ligações da carteira» aprova ou rejeita uma a uma ou por grupo; só a aprovação escreve a ligação, com registo de quem e quando, e anular retira apenas a ligação que a aprovação criou. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?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
|
||||
{
|
||||
/**
|
||||
* Carteira 4.3: each proposed opportunity ↔ project/corridor/cluster link keeps its source and evidence and is
|
||||
* only written to the opportunity_* link tables when a person approves it. link_created tells whether the
|
||||
* approval created the link, so undoing never removes a link that already existed.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('portfolio_link_reviews', function (Blueprint $t) {
|
||||
$t->uuid('id')->primary();
|
||||
$t->foreignId('opportunity_id')->constrained('opportunities')->restrictOnDelete();
|
||||
$t->string('target_type', 20);
|
||||
$t->uuid('target_id');
|
||||
$t->string('relation', 40);
|
||||
$t->text('source');
|
||||
$t->text('evidence');
|
||||
$t->string('status', 20)->default('pending');
|
||||
$t->boolean('link_created')->default(false);
|
||||
$t->foreignId('decided_by')->nullable()->constrained('users')->restrictOnDelete();
|
||||
$t->timestampTz('decided_at')->nullable();
|
||||
$t->text('decision_note')->nullable();
|
||||
$t->timestampsTz();
|
||||
$t->unique(['opportunity_id', 'target_type', 'target_id']);
|
||||
$t->index(['status', 'target_type', 'target_id']);
|
||||
});
|
||||
DB::statement("ALTER TABLE portfolio_link_reviews
|
||||
ADD CONSTRAINT portfolio_link_reviews_target_check CHECK (target_type IN ('project','corridor','cluster')),
|
||||
ADD CONSTRAINT portfolio_link_reviews_relation_check CHECK (relation IN ('same_project','within_anchor_area','related_supplier','corridor_context','cluster_context')),
|
||||
ADD CONSTRAINT portfolio_link_reviews_status_check CHECK (status IN ('pending','approved','rejected')),
|
||||
ADD CONSTRAINT portfolio_link_reviews_decision_check CHECK ((status = 'pending') = (decided_at IS NULL) AND (status = 'pending') = (decided_by IS NULL))");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('portfolio_link_reviews');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user