Files
SGF/scripts/sgf-remunerations-backup.php
T
2026-11-11 09:00:17 +02:00

6 lines
1.3 KiB
PHP

<?php
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';
$previous=json_decode(file_get_contents($s['root'].'/single-integration/20261111-073116-5f71ef3d/statements-installation.json'),true);$qualified=$previous['identical_original_tables'];$before=[];$order=fn($table)=>in_array($table,['sr_outbox','sr_deliveries'],true)?'event_id':(in_array($table,['sc_catalogue_meta','pd_due_meta','fo_meta','fs_meta'],true)?'policy':(in_array($table,['fs_results','fs_result_lines'],true)?'snapshot_key':'id'));foreach($qualified as$key){[$name,$table]=explode('.',$key);$db=$name==='host'?$host:$native;$before[$name][$table]=$db->table($table)->orderBy($order($table))->when($table==='fs_result_lines',fn($q)=>$q->orderBy('account_id'))->get()->toJson();}$binding=hash_file('sha256',$s['root'].'/binding.json');
$before['binding']=hash_file('sha256',$s['root'].'/binding.json');$before['single_binding']=hash_file('sha256',$s['root'].'/single-bindings.json');$before['stock_binding']=hash_file('sha256',$s['root'].'/stock-binding.json');file_put_contents($work.'/preservation-private.json',json_encode($before));file_put_contents($s['root'].'/remunerations-backup-pointer.json',json_encode(['root'=>$work]));echo json_encode(['passed'=>true,'private_backup'=>$work,'database_writes'=>0]).PHP_EOL;