commit melhorias compras5
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-22 19:39:09 +02:00
parent 36dcfdf00c
commit db1615fac1
79 changed files with 4082 additions and 120 deletions
@@ -0,0 +1,32 @@
<?php
use App\Services\BudgetDistributionSchema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
// Deliberately outside automatic migrations. Only the reviewed installer supplies this scope.
return new class extends Migration
{
public function up(): void
{
$db = DB::connection();
$scope = config('budget-distributions.schema_installation');
if (! app()->runningInConsole() || ! app()->environment(['local', 'testing', 'payable-testing'])
|| $db->getDriverName() !== 'pgsql' || $db->getConfig('host') !== '127.0.0.1'
|| ! is_array($scope) || ($scope['database'] ?? null) !== $db->getDatabaseName()
|| ($scope['username'] ?? null) !== $db->getConfig('username')
|| ! preg_match('/^compras_(receipts_test|distribution_restore)_[a-f0-9]{12}$/D', $db->getDatabaseName())) {
throw new LogicException('Distribution pilot schema requires the exact authorised installer scope.');
}
$identity = $db->selectOne('select current_database() as db, current_user as role');
if ($identity === null || $identity->db !== $scope['database'] || $identity->role !== $scope['username']) {
throw new LogicException('Distribution pilot schema identity mismatch.');
}
BudgetDistributionSchema::install();
}
public function down(): void
{
throw new LogicException('Preserve distribution history; use reviewed recovery or a compatible forward correction.');
}
};