mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-25 16:42:16 +03:00
Two independently-merged PRs (#10263 agentic-conversation-tracking-v4 and #10362 exclusive-managed-session-leases) each picked migration slot 155 against different base states, landing a real collision on release/v3.8.50 (155_agentic_conversations.sql vs 155_exclusive_connection_leases.sql; #10263 also claimed 156 via 156_conversation_turn_nodes.sql). Renumbered #10362's migration to the next free slot (157) and updated its own regression test (exclusive-connection-leases.test.ts) that asserted the literal filename/slot. No retroactive guard needed: CREATE TABLE IF NOT EXISTS is idempotent under either number. Confirmed via check-migration-numbering.mjs (154 migrations, 0 duplicates) and the full exclusive-connection-leases test suite (11/11 pass).
31 lines
1.1 KiB
SQL
31 lines
1.1 KiB
SQL
CREATE TABLE IF NOT EXISTS exclusive_connection_leases (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
lease_owner_hash TEXT NOT NULL
|
|
CHECK (length(lease_owner_hash) = 64 AND lease_owner_hash = lower(lease_owner_hash)),
|
|
api_key_id TEXT NOT NULL,
|
|
provider TEXT NOT NULL,
|
|
connection_id TEXT NOT NULL,
|
|
generation INTEGER NOT NULL CHECK (generation > 0),
|
|
state TEXT NOT NULL
|
|
CHECK (state IN ('ACTIVE', 'RELEASED', 'EXPIRED', 'INVALIDATED')),
|
|
acquired_at TEXT NOT NULL,
|
|
renewed_at TEXT NOT NULL,
|
|
expires_at TEXT NOT NULL,
|
|
ended_at TEXT,
|
|
end_reason TEXT
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_exclusive_lease_active_owner
|
|
ON exclusive_connection_leases(lease_owner_hash)
|
|
WHERE state = 'ACTIVE';
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_exclusive_lease_active_connection
|
|
ON exclusive_connection_leases(connection_id)
|
|
WHERE state = 'ACTIVE';
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_exclusive_lease_owner_history
|
|
ON exclusive_connection_leases(lease_owner_hash, generation, id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_exclusive_lease_expiry
|
|
ON exclusive_connection_leases(state, expires_at);
|