backend outbox integration

This commit is contained in:
m
2026-09-12 22:08:52 +02:00
parent 1460fdfe0e
commit cc533a3b24
6 changed files with 139 additions and 28 deletions
@@ -0,0 +1,4 @@
ALTER TABLE operations DROP CONSTRAINT operations_operation_id_hex_check;
ALTER TABLE operations
ALTER COLUMN operation_id TYPE BIGINT USING operation_id::bigint;
@@ -0,0 +1,12 @@
-- operation_id outbox : BIGINT → TEXT 32-hex (UUID client-generated)
-- cf. docs/api-v1.md §6.1 — idempotence UNIQUE(device_id, operation_id)
-- survit car le nom de colonne ne change pas.
-- Les traces héritées (ancien protocole, operation_id INTEGER) sont converties
-- en 32-hex paddé (LPAD injectif → l'unicité (device_id, operation_id) tient,
-- et le CHECK 32-hex est satisfait ; valeurs jamais rejouées, traces inertes).
ALTER TABLE operations
ALTER COLUMN operation_id TYPE TEXT USING LPAD(operation_id::text, 32, '0');
ALTER TABLE operations
ADD CONSTRAINT operations_operation_id_hex_check
CHECK (operation_id ~ '^[0-9a-f]{32}$');