make(Kernel::class)->bootstrap(); $base = DB::connection('pgsql')->getConfig(); unset($base['name']); config(['database.connections.commercial_preflight' => [...$base, 'url' => null, 'host' => $settings['DB_HOST'], 'database' => $settings['DB_DATABASE'], 'username' => $settings['DB_USERNAME'], 'password' => $settings['DB_PASSWORD']]]); $db = DB::connection('commercial_preflight'); $db->beginTransaction(); try { $db->statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY'); $identity = $db->selectOne('select current_database() as db, current_user as role'); if ($identity->db !== $settings['DB_DATABASE'] || $identity->role !== $settings['DB_USERNAME']) { throw new LogicException('Identidade do destino não confirmada.'); } $schema = $db->getSchemaBuilder(); $targets = ['2026_11_21_000001_create_quotation_exchange_rates.php', '2026_11_21_000002_add_supplier_bank_account_keys.php']; $hashes = []; foreach ($targets as $name) { $hashes[$name] = hash_file('sha256', $root.'/database/migrations/'.$name); } $report = ['inspection_only' => true, 'target' => 'SGC local 8005', 'consistent_read_only' => true, 'public_tables' => (int) $db->selectOne("select count(*) as n from pg_tables where schemaname='public'")->n, 'fx_table_present' => $schema->hasTable('quotation_exchange_rates'), 'quotation_fx_column_present' => $schema->hasColumn('quotations', 'exchange_basis'), 'bank_account_key_present' => $schema->hasColumn('supplier_bank_details', 'account_key'), 'migration_hashes' => $hashes, 'pilot_manifest_sha256' => hash_file('sha256', $root.'/public/build/manifest.json')]; $db->commit(); echo json_encode($report, JSON_THROW_ON_ERROR).PHP_EOL; } finally { if ($db->transactionLevel() !== 0) { $db->rollBack(); } DB::purge('commercial_preflight'); }