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}$');
+4 -3
View File
@@ -179,7 +179,7 @@ func TestMigrationsUpDown(t *testing.T) {
t.Error("FK resources.user_id → users(id) manquante après 000007")
}
// operation_id outbox = id client (INTEGER) — cf. docs/api-v1.md §6.1
// operation_id outbox = UUID 32-hex client-generated — cf. docs/api-v1.md §6.1
var opType string
err = conn.QueryRow(`
SELECT data_type FROM information_schema.columns
@@ -187,9 +187,10 @@ func TestMigrationsUpDown(t *testing.T) {
if err != nil {
t.Fatalf("operation_id type: %v", err)
}
if opType != "bigint" {
t.Errorf("operation_id attendu bigint, got %s", opType)
if opType != "text" {
t.Errorf("operation_id attendu text, got %s", opType)
}
assertHexCheck(t, conn, "operations", "operation_id")
var resourceTypeCheck int
err = conn.QueryRow(`