Files
SGF/scripts/document-preservation.php
T
nala f8d57b52aa Preserva classificacao contabilistica aceite e bases locais
Regista aceitacao funcional do primeiro incremento PGC-NIRF e preserva as dependencias documentais e tecnicas existentes. A validacao do calculo fiscal continua separada e pendente. Sem credenciais, bases operacionais ou publicacao.
2026-10-26 13:47:11 +02:00

20 lines
1.5 KiB
PHP

<?php
require __DIR__.'/../vendor/autoload.php';
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
if (! \App\Modules\Identity\Services\LocalDatabaseGuard::allows()) { throw new RuntimeException('Own local development database required.'); }
$path = 'C:/laragon/data/sgf-tempo/run/document-preservation.json';
$tables = ['users','tenants','companies','units','company_memberships','a_clients','a_services','a_service_drafts','a_billing_drafts','a_history','a_events','a_outbox','a_pending','a_commands','b_internal_confirmations','doc_records','doc_history'];
$state = [];
foreach ($tables as $table) {
$rows = \Illuminate\Support\Facades\DB::table($table)->get()->map(fn ($row) => json_encode((array) $row, JSON_THROW_ON_ERROR))->all(); sort($rows);
$state[$table] = ['count' => count($rows), 'digest' => hash('sha256', implode("\n", $rows))];
}
if (($argv[1] ?? '') === 'before') { file_put_contents($path, json_encode($state, JSON_THROW_ON_ERROR)); echo "Local preservation baseline recorded; no record values displayed.\n"; }
elseif (($argv[1] ?? '') === 'after') {
$before = json_decode(file_get_contents($path), true, 32, JSON_THROW_ON_ERROR);
if ($before !== $state) { throw new RuntimeException('Existing record preservation comparison failed; inspect locally without printing values.'); }
echo "Existing identity, A records and B1 snapshots match the pre-migration baseline exactly.\n";
} else { throw new RuntimeException('Usage: document-preservation.php before|after'); }