9 lines
875 B
PHP
9 lines
875 B
PHP
<?php
|
|
require __DIR__.'/boot-QA.php';
|
|
$tables=Illuminate\Support\Facades\DB::select("SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename");$hashes=[];
|
|
foreach($tables as$t){$name=$t->tablename;$hashes[$name]=Illuminate\Support\Facades\DB::selectOne('SELECT md5(COALESCE(string_agg(md5(row_to_json(t)::text),\'\' ORDER BY row_to_json(t)::text),\'\')) AS hash FROM "'.str_replace('"','""',$name).'" t')->hash;}
|
|
$before=json_decode(file_get_contents(__DIR__.'/BASELINE-QA.json'),true)['tables'];$changed=[];
|
|
foreach($hashes as$name=>$hash){if(($before[$name]??null)!==$hash)$changed[]=$name;}
|
|
$result=['target'=>$target,'table_count'=>count($hashes),'changed_tables'=>$changed,'tables'=>$hashes];
|
|
file_put_contents(__DIR__.'/FINAL-QA.json',json_encode($result,JSON_PRETTY_PRINT));echo json_encode(['tables'=>count($hashes),'changed_tables'=>$changed]);
|