make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); use Illuminate\Support\Facades\DB; $c=config('database.connections.'.config('database.default'));if($c['database']!=='investemoz'||(int)$c['port']!==5432)throw new RuntimeException('Destination guard'); DB::beginTransaction();DB::statement('SET TRANSACTION READ ONLY');try{ $p=app(App\Services\VirtualDeskInstallation::class)->preview();if(!$p['installed']||$p['pendingMigrations']!==[])throw new RuntimeException('Installation incomplete'); $ledger=DB::table('migrations')->where('migration','2026_10_09_190000_prepare_investor_path')->get(['migration','batch']);if($ledger->count()!==1)throw new RuntimeException('Ledger mismatch'); $columns=DB::select("select table_name,column_name,data_type,is_nullable from information_schema.columns where table_schema='public' and ((table_name='investor_journeys' and column_name='path_definition_id') or (table_name='journey_steps' and column_name='path_detail')) order by table_name");if(count($columns)!==2)throw new RuntimeException('Columns absent'); $definition=DB::table('questionnaire_versions')->where('id',config('investor-path.definition_id'))->first(['id','code','version_no','status']);if(!$definition||$definition->code!=='investor-path-19'||$definition->status!=='published')throw new RuntimeException('Definition mismatch'); $audit=DB::table('audit_events')->where('action','desk_installed')->orderByDesc('created_at')->first(['actor_user_id','after_data','created_at']);$a=json_decode($audit->after_data,true,512,JSON_THROW_ON_ERROR);if($a['code_hash']!==$p['code_hash'])throw new RuntimeException('Audit mismatch'); $v=['at'=>gmdate('c'),'target'=>$p['target'],'SQL_read_only'=>true,'installed'=>true,'migration_ledger'=>$ledger,'columns'=>$columns,'definition'=>$definition,'audit'=>['actor_user_id'=>$audit->actor_user_id,'at'=>$audit->created_at,'code_hash'=>$a['code_hash']],'path_enabled'=>(bool)config('investor-path.enabled'),'existing_journeys_bound'=>DB::table('investor_journeys')->whereNotNull('path_definition_id')->count(),'existing_step_details'=>DB::table('journey_steps')->whereNotNull('path_detail')->count(),'counts'=>$p['counts'],'pending_migrations'=>$p['pendingMigrations']];file_put_contents(__DIR__.'/B-activation-installed-20261015.json',json_encode($v,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($v,JSON_THROW_ON_ERROR); }finally{DB::rollBack();}