@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tempo\Finance\GeneralLedger\LedgerSchema;
|
||||
|
||||
/** Compose already-authorised optional contracts only in the owned non-elevated ledger QA database. */
|
||||
function integratedPurchasingQaSchema(): array
|
||||
{
|
||||
LedgerSchema::assertSynthetic(DB::connection());
|
||||
if (! app()->environment('testing') || DB::connection()->getConfig('host') !== '127.0.0.1'
|
||||
|| DB::connection()->getConfig('port') !== '55439'
|
||||
|| ! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', DB::connection()->getDatabaseName())) {
|
||||
throw new LogicException('Integrated purchasing schema requires the dedicated owned QA composition.');
|
||||
}
|
||||
$migrations = [
|
||||
'2026_11_22_000004_create_budget_distributions.php',
|
||||
'2026_11_22_000007_create_budget_order_parts.php',
|
||||
'2026_11_22_000008_create_purchase_order_sources.php',
|
||||
'2026_11_22_000009_create_budget_landed_costs.php',
|
||||
'2026_11_27_000001_add_requisition_cycles.php',
|
||||
];
|
||||
$tables = ['budget_distributions', 'budget_distribution_events', 'budget_distribution_entries', 'budget_distribution_consumptions',
|
||||
'budget_order_commands', 'budget_order_bindings', 'budget_order_allocations', 'budget_order_consumptions',
|
||||
'purchase_order_sources', 'budget_landed_commands', 'budget_landed_entries', 'budget_requisition_cycles'];
|
||||
foreach ($tables as $table) {
|
||||
if (Schema::hasTable($table)) {
|
||||
throw new LogicException('Never reinstall or repair a partial integrated QA schema implicitly.');
|
||||
}
|
||||
}
|
||||
$columns = ['requisitions' => 'approval_cycle', 'approval_steps' => 'approval_cycle', 'budget_entries' => 'requisition_cycle',
|
||||
'budget_distributions' => 'requisition_cycle', 'purchase_orders' => 'order_key'];
|
||||
DB::transaction(function () use ($migrations, $tables, $columns) {
|
||||
foreach ($migrations as $migration) {
|
||||
(require base_path('database/qa-migrations/'.$migration))->up();
|
||||
}
|
||||
foreach ($tables as $table) {
|
||||
if (! Schema::hasTable($table)) {
|
||||
throw new LogicException('An integrated QA contract table was not created.');
|
||||
}
|
||||
}
|
||||
foreach ($columns as $table => $column) {
|
||||
if (! Schema::hasColumn($table, $column)) {
|
||||
throw new LogicException('An integrated QA contract column was not created.');
|
||||
}
|
||||
}
|
||||
});
|
||||
config(['requisition-expiry.qa_enabled' => true]);
|
||||
|
||||
return ['migrations' => array_map(fn ($name) => ['name' => $name, 'sha256' => hash_file('sha256', base_path('database/qa-migrations/'.$name))], $migrations),
|
||||
'verified_tables' => $tables, 'verified_columns' => $columns];
|
||||
}
|
||||
Reference in New Issue
Block a user