27 lines
957 B
PHP
27 lines
957 B
PHP
<?php
|
|
|
|
use App\Services\BudgetDistributionSchema;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
// Explicit QA path: not discovered by the normal application migration directory.
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$db = DB::connection();
|
|
$isolated = ($db->getDriverName() === 'sqlite' && $db->getDatabaseName() === ':memory:')
|
|
|| ($db->getDriverName() === 'pgsql' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $db->getDatabaseName()));
|
|
if (! app()->environment('testing') || ! $isolated) {
|
|
throw new LogicException('Distribution schema requires the guarded disposable QA database.');
|
|
}
|
|
|
|
BudgetDistributionSchema::install();
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
throw new LogicException('Use the verified pre-extension backup; distribution history is not deleted by a downgrade.');
|
|
}
|
|
};
|