Files
Investidor-V2/outputs/investmoz-parques-ativacao-20261016/status-readonly.php
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

11 lines
1.4 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');set_exception_handler(function(Throwable $e){fwrite(STDERR,'Read-only status stopped: '.$e::class.PHP_EOL);exit(1);});
$root=dirname(__DIR__,2);require $root.'/vendor/autoload.php';$app=require $root.'/bootstrap/app.php';
(new Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables)->bootstrap($app);(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app);
$c=config('database.connections.'.config('database.default'));
if($c['driver']!=='pgsql'||$c['database']!=='investemoz'||(int)$c['port']!==5432||!in_array($c['host'],['127.0.0.1','localhost'])||!empty($c['url']))throw new RuntimeException('Destination guard');
$db=new PDO('pgsql:host='.$c['host'].';port=5432;dbname=investemoz',$c['username'],$c['password'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);$db->exec('BEGIN READ ONLY');
try{echo json_encode(['read_only'=>true,'ledger'=>(int)$db->query("SELECT count(*) FROM migrations WHERE migration='2026_10_16_130000_add_investment_zone_editorial_draft'")->fetchColumn(),
'column'=>(int)$db->query("SELECT count(*) FROM information_schema.columns WHERE table_schema='public' AND table_name='investment_zones' AND column_name='editorial_draft'")->fetchColumn(),
'installation_events'=>(int)$db->query("SELECT count(*) FROM audit_events WHERE source_system='investment-zone-profile-installation'")->fetchColumn()]).PHP_EOL;}finally{$db->exec('ROLLBACK');}