'public_documents_20261018_test','port'=>55441])throw new RuntimeException('Exact QA required'); $hashes=[];foreach(['documents','portal_resources','portal_resource_links','portal_resource_revisions','audit_events']as$table){$rows=DB::select('SELECT row_to_json(t)::text AS row FROM "'.$table.'" t ORDER BY row_to_json(t)::text');$hashes[$table]=['rows'=>count($rows),'sha256'=>hash('sha256',implode("\n",array_column($rows,'row')))];} if(($argv[1]??'')==='copy-files'){ $root=dirname(__DIR__,2);$copied=0; foreach(DB::table('documents')->whereNotNull('storage_key')->get(['storage_key'])as$d){$from=realpath($root.'/storage/app/private/'.$d->storage_key);$dest=storage_path('app/private/'.$d->storage_key);if(!$from||!str_starts_with(str_replace('\\','/',$from),str_replace('\\','/',realpath($root.'/storage/app/private')).'/'))continue;if(!is_dir(dirname($dest)))mkdir(dirname($dest),0700,true);if(!is_file($dest)||hash_file('sha256',$dest)!==hash_file('sha256',$from)){if(!copy($from,$dest))throw new RuntimeException('QA binary copy');$copied++;}} } echo json_encode(['target'=>$target,'tables'=>$hashes,'public_resources'=>DB::table('portal_resources')->where('published',true)->pluck('document_id','id'),'private_resource_ids'=>DB::table('portal_resources')->where('published',false)->pluck('id')],JSON_THROW_ON_ERROR).PHP_EOL;