Files
fewo-stommer/app/Console/Commands/ProcessFingerprint.php
T

35 lines
1.7 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* Checksums of what an update must never change by itself (docs/Prozessarchitektur/Architektur/06 U-F, step 6):
* the cases with their contract data and frozen profile, the channels' process configuration and the calendar blocks.
* Run before and after a deployment and compare. Only reads; prints no personal data.
*/
#[Signature('process:fingerprint')]
#[Description('Print checksums of cases, channel configurations and calendar blocks (compare before/after a deployment)')]
class ProcessFingerprint extends Command
{
public function handle(): int
{
$hash = fn ($query): string => md5($query->get()->map(fn (object $row): string => (string) json_encode($row))->implode("\n"));
$this->line((string) json_encode([
'bookings' => DB::table('bookings')->count(),
'channels' => DB::table('channels')->count(),
'blocked_periods' => DB::table('blocked_periods')->count(),
'h_bookings' => $hash(DB::table('bookings')->orderBy('id')->select('id', 'status', 'profile', 'total', 'quote', 'offer_terms', 'acceptance', 'arrival', 'departure', 'hold_expires_at', 'deposit_due_on', 'balance_due_on')),
'h_overrides' => $hash(DB::table('channels')->orderBy('id')->select('id', 'process_overrides', 'booking_model', 'case_intake')),
'h_blocks' => $hash(DB::table('blocked_periods')->orderBy('id')->select('id', 'starts_on', 'ends_on', 'source', 'channel_id', 'linked_booking_id', 'deleted_at')),
], JSON_PRETTY_PRINT));
return self::SUCCESS;
}
}