Files
SGF/scripts/modular-installed-snapshot.php
2026-11-02 08:06:45 +02:00

15 lines
1.1 KiB
PHP

<?php
// Read-only fingerprints. No identities, credentials or business documents printed.
require __DIR__.'/../vendor/autoload.php';
$app=require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
use Illuminate\Support\Facades\DB;
$identity=DB::selectOne('SELECT current_database() AS database,current_user AS role,inet_server_port() AS port');
$tables=[];
foreach(['permission_grants','company_memberships','identity_audit'] as $table){
$r=DB::selectOne("SELECT count(*) AS rows,md5(coalesce(string_agg(row_to_json(t)::text,E'\\n' ORDER BY row_to_json(t)::text),'')) AS fingerprint FROM {$table} t");
$tables[$table]=['rows'=>(int)$r->rows,'fingerprint'=>$r->fingerprint];
}
echo json_encode(['database'=>(array)$identity,'tables'=>$tables,'guard_sha256'=>hash_file('sha256',base_path('app/Shared/Testing/TestingDatabaseGuard.php')),'purchasing_pointer_sha256'=>is_file(base_path('packages/purchasing/current.json'))?hash_file('sha256',base_path('packages/purchasing/current.json')):null],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR).PHP_EOL;