18 lines
744 B
SQL
18 lines
744 B
SQL
-- Ledger fixes.
|
|
-- * Mutating tools that need no Computer (memory, schedules) are journaled
|
|
-- too, so computer_id must be nullable.
|
|
-- * The outbox is polled every 200 ms; give the undelivered scan an index and
|
|
-- let retention drop delivered rows.
|
|
-- * `computer_operations.id` is now `{bot_id}:{operation_id}`; the extra
|
|
-- (id, payload_hash) unique index never added anything over the PK.
|
|
|
|
ALTER TABLE computer_operations ALTER COLUMN computer_id DROP NOT NULL;
|
|
|
|
DROP INDEX IF EXISTS computer_operations_id_hash;
|
|
|
|
CREATE INDEX IF NOT EXISTS operation_outbox_pending_idx
|
|
ON operation_outbox (created_at) WHERE NOT delivered;
|
|
|
|
CREATE INDEX IF NOT EXISTS computer_operations_bot_idx
|
|
ON computer_operations (bot_id, created_at);
|