@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// Synthetic preview only, fixed isolated restored QA database; never writes active data.
|
||||
foreach (['APP_ENV' => 'testing', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441',
|
||||
'DB_DATABASE' => 'anchor_restore_20261007_test', 'DB_USERNAME' => 'postgres', 'DB_PASSWORD' => '', 'DB_URL' => ''] as $key => $value) {
|
||||
@@ -8,23 +12,23 @@ foreach (['APP_ENV' => 'testing', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.
|
||||
}
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$identity = Illuminate\Support\Facades\DB::selectOne('select current_database() as database, inet_server_port() as port');
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
$identity = DB::selectOne('select current_database() as database, inet_server_port() as port');
|
||||
if ($identity->database !== 'anchor_restore_20261007_test' || (int) $identity->port !== 55441) {
|
||||
throw new RuntimeException('Isolated QA required');
|
||||
}
|
||||
$root = storage_path('app/private/anchor-project-reconciliation');
|
||||
$fixture = json_decode(file_get_contents($root.'/qa-browser-fixture.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
$dossier = Illuminate\Support\Facades\DB::table('investment_dossiers')->where('id', $fixture['project_dossier'])->first();
|
||||
$project = Illuminate\Support\Facades\DB::table('projects')->where('id', $dossier->project_id)->first();
|
||||
$dossier = DB::table('investment_dossiers')->where('id', $fixture['project_dossier'])->first();
|
||||
$project = DB::table('projects')->where('id', $dossier->project_id)->first();
|
||||
if (! str_starts_with($project->code, 'QA-')) {
|
||||
throw new RuntimeException('Synthetic project required');
|
||||
}
|
||||
$site = Illuminate\Support\Facades\DB::table('project_locations')->where('project_id', $project->id)->where('role', 'primary')->first();
|
||||
$site = DB::table('project_locations')->where('project_id', $project->id)->where('role', 'primary')->first();
|
||||
$nodes = [];
|
||||
$id = $site->geo_location_id;
|
||||
while ($id) {
|
||||
$node = Illuminate\Support\Facades\DB::table('geo_locations')->where('id', $id)->first();
|
||||
$node = DB::table('geo_locations')->where('id', $id)->first();
|
||||
$nodes[$node->location_type] = $node;
|
||||
$id = $node->parent_id;
|
||||
}
|
||||
@@ -36,7 +40,7 @@ foreach ([['province', 'secondary'], ['district', 'impact'], ['admin_post', 'sec
|
||||
$rows[] = [...$base, 'geo_location_id' => $nodes[$type]->id, 'name' => $nodes[$type]->name, 'role' => $role, 'existing' => false];
|
||||
}
|
||||
$rows[2]['source_quote'] = '';
|
||||
$rows[3]['province_id'] = (string) Illuminate\Support\Str::uuid();
|
||||
$rows[3]['province_id'] = (string) Str::uuid();
|
||||
$directory = $root.'/qa-territorial-preview';
|
||||
if (! is_dir($directory)) {
|
||||
mkdir($directory, 0700, true);
|
||||
|
||||
Reference in New Issue
Block a user