26 lines
1005 B
PHP
26 lines
1005 B
PHP
<?php
|
|
|
|
use App\Services\RequisitionCycleSchema;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
// Explicit cycle-contract QA only. Never discovered by operational migrate.
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$db = DB::connection();
|
|
$isolated = ($db->getDriverName() === 'sqlite' && $db->getDatabaseName() === ':memory:')
|
|
|| ($db->getDriverName() === 'pgsql' && $db->getConfig('host') === '127.0.0.1' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $db->getDatabaseName()));
|
|
if (! app()->environment('testing') || ! $isolated) {
|
|
throw new LogicException('Approval and budget cycle schema requires isolated QA.');
|
|
}
|
|
RequisitionCycleSchema::install($db);
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
throw new LogicException('Restore the verified pre-cycle backup and compatible artifact; never delete previous approval or financial cycles.');
|
|
}
|
|
};
|