schema(ticket): add write intent records
parent
a83a4d7675
commit
a249c8abea
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$schema = file_get_contents(dirname(__DIR__) . '/sql/ss.sql');
|
||||
|
||||
$assert = static function ($condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$assert(str_contains($schema, 'CREATE TABLE `ticket_write_requests`'),
|
||||
'Fresh schema is missing durable ticket write intents.');
|
||||
foreach (['actor_user_id', 'request_key', 'request_hash', 'operation', 'ticket_id', 'message_id', 'created_at'] as $column) {
|
||||
$assert(str_contains($schema, '`' . $column . '`'),
|
||||
'Ticket write intent schema is missing ' . $column . '.');
|
||||
}
|
||||
$assert(str_contains($schema, 'UNIQUE KEY `ticket_write_actor_key` (`actor_user_id`,`request_key`)'),
|
||||
'Ticket write intents are not unique per actor and request key.');
|
||||
$assert(str_contains($schema, 'CHARACTER SET ascii COLLATE ascii_bin'),
|
||||
'Ticket idempotency keys and hashes must use exact ASCII comparison.');
|
||||
$assert(str_contains($schema, 'CREATE TABLE `ticket_user_guards`')
|
||||
&& str_contains($schema, 'PRIMARY KEY (`user_id`)'),
|
||||
'Ticket policy writes are missing a user-scoped lock row.');
|
||||
|
||||
echo "Ticket write intent schema contract passed.\n";
|
||||
Loading…
Reference in New Issue