oportunidades 4
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 07:03:59 +02:00
parent e662230df7
commit 6ddafc95ba
179 changed files with 22750 additions and 933 deletions
@@ -201,7 +201,6 @@ SQL);
}
foreach (self::TABLES as $table) {
if (Schema::hasTable($table)) {
DB::statement("ALTER TABLE public.{$table} DISABLE ROW LEVEL SECURITY");
$query = DB::table($table);
if ($table === 'questionnaire_versions') {
$query->where('id', '<>', '61000100-0000-4000-8000-000000000001');
@@ -212,6 +211,9 @@ SQL);
}
}
foreach (self::TABLES as $table) {
if (Schema::hasTable($table)) {
DB::statement("ALTER TABLE public.{$table} DISABLE ROW LEVEL SECURITY");
}
Schema::dropIfExists($table);
}
DB::statement('DROP FUNCTION IF EXISTS public.investmoz_reject_simulation_audit_change() RESTRICT');
@@ -0,0 +1,48 @@
<?php
use App\Services\InvestorPathDefinition;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
if (! app()->environment('testing') && ! config('investor-path.authenticated_installation')) {
throw new RuntimeException('Investor path installation requires an authenticated, verified activation plan.');
}
if (DB::connection()->getDriverName() !== 'pgsql') {
throw new RuntimeException('Investor path requires PostgreSQL.');
}
DB::statement('ALTER TABLE investor_journeys ADD COLUMN path_definition_id uuid REFERENCES questionnaire_versions(id) ON DELETE RESTRICT');
DB::statement('ALTER TABLE journey_steps ADD COLUMN path_detail text');
$definition = InvestorPathDefinition::snapshot();
InvestorPathDefinition::validate($definition);
$existing = DB::table('questionnaire_versions')->where('id', config('investor-path.definition_id'))->first();
if ($existing) {
$stored = json_decode($existing->schema_snapshot, true, 512, JSON_THROW_ON_ERROR);
if (! is_array($stored) || Arr::sortRecursive($stored) !== Arr::sortRecursive($definition) || $existing->code !== 'investor-path-19' || $existing->status !== 'published') {
throw new RuntimeException('Published definition differs: create a new version rather than overwrite it.');
}
} else {
DB::table('questionnaire_versions')->insert([
'id' => config('investor-path.definition_id'), 'code' => 'investor-path-19', 'version_no' => 1,
'locale' => 'pt-MZ', 'schema_snapshot' => json_encode($definition, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE),
'status' => 'published', 'valid_from' => '2026-10-09',
]);
}
// Definition availability does not enable the feature or reinterpret existing journeys.
}
public function down(): void
{
if (DB::table('investor_journeys')->whereNotNull('path_definition_id')->exists()
|| DB::table('journey_steps')->whereNotNull('path_detail')->exists()) {
throw new RuntimeException('Preserve investor path history: disable feature or restore a verified backup instead of dropping used columns.');
}
DB::statement('ALTER TABLE journey_steps DROP COLUMN path_detail');
DB::statement('ALTER TABLE investor_journeys DROP COLUMN path_definition_id');
// Published questionnaire versions are immutable; retain the unused definition and its provenance.
}
};