in_array($table,['sr_outbox','sr_deliveries'],true)?'event_id':(in_array($table,['sc_catalogue_meta','pd_due_meta','fo_meta','fs_meta','rm_meta'],true)?'policy':($table==='hr_qa_profiles'?'profile_key':(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');file_put_contents($work.'/preservation-private.json',json_encode($before)); $files=['routes/web.php', 'app/Modules/HumanResources/Remunerations.php', 'app/Modules/HumanResources/Http/RemunerationsController.php', 'app/Shared/Installation/HumanResourcesProfiles.php', 'app/Shared/Installation/PresentationEntry.php', 'app/Shared/Context/ModuleNavigation.php', 'app/Modules/Identity/Services/IdentityWorkflow.php', 'resources/js/RemunerationsWorkspace.jsx', 'resources/js/app.jsx', 'resources/js/WorkspaceNavigation.jsx', 'resources/js/ModuleNavigation.jsx', 'resources/js/statement-download.js', 'resources/js/presentation-landing.js', 'resources/js/workspace-overview.js', 'resources/views/sgf-presentation-entry.blade.php', 'database/sql/remunerations.sql', 'docs/integration/sgf-human-resources-access-proposal.json'];foreach($files as$file)if(str_ends_with($file,'.php'))(new Symfony\Component\Process\Process([PHP_BINARY,'-l',$repo.'/'.$file]))->mustRun();$hashes=[];$copy=function($src,$file)use($s,$work,&$hashes){$dest=$s['app'].'/'.$file;$backup=$work.'/before/'.$file;if(is_file($dest)){if(!is_dir(dirname($backup)))mkdir(dirname($backup),0700,true);copy($dest,$backup);}if(!is_dir(dirname($dest)))mkdir(dirname($dest),0700,true);copy($src,$dest);$hashes[$file]=hash_file('sha256',$dest);};foreach($files as$file)$copy($repo.'/'.$file,$file); $configs=['remunerations'=>['enabled'=>true,'schema_sha256'=>hash_file('sha256',$repo.'/database/sql/remunerations.sql')],'human_resources'=>['enabled'=>true,'profiles_sha256'=>App\Shared\Installation\HumanResourcesProfiles::fingerprint(App\Shared\Installation\HumanResourcesProfiles::policy())]]; $modules=require $s['app'].'/config/modules.php';$company=$modules['companies']['1:2']??[];foreach(['contracted','enabled']as$key)$company[$key]=array_values(array_unique([...($company[$key]??($key==='enabled'?($company['contracted']??$modules['contracted']):$modules['contracted'])),'human_resources']));$modules['companies']['1:2']=$company;$configs['modules']=$modules; foreach($configs as$name=>$data){$file=$work.'/'.$name.'.php';file_put_contents($file,"$tables){$db=$name==='host'?$host:$native;foreach($tables as$table=>$json){if($db->table($table)->orderBy($order($table))->when($table==='fs_result_lines',fn($q)=>$q->orderBy('account_id'))->get()->toJson()!==$json)throw new LogicException('Original facts changed '.$table);$checks[]=$name.'.'.$table;}}if($binding!==hash_file('sha256',$s['root'].'/binding.json'))throw new LogicException('Binding changed');file_put_contents($work.'/hr-installation.json',json_encode(['passed'=>true,'hashes'=>$hashes,'identical_original_tables'=>$checks,'business_commands'=>0,'new_grants'=>0,'new_demo'=>false,'cache_cleared'=>false,'native_writes'=>0,'binding_unchanged'=>true],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'proof'=>$work.'/hr-installation.json']).PHP_EOL;