@fonderie/events 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS fonderie_events (
|
|
2
|
+
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
3
|
+
type TEXT NOT NULL,
|
|
4
|
+
payload JSONB NOT NULL DEFAULT '{}',
|
|
5
|
+
meta JSONB NOT NULL DEFAULT '{}',
|
|
6
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
CREATE INDEX IF NOT EXISTS fonderie_events_created_idx
|
|
10
|
+
ON fonderie_events (created_at);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Drop mutable delivery columns from fonderie_events (no-op on fresh installs)
|
|
2
|
+
ALTER TABLE fonderie_events
|
|
3
|
+
DROP COLUMN IF EXISTS status,
|
|
4
|
+
DROP COLUMN IF EXISTS attempts,
|
|
5
|
+
DROP COLUMN IF EXISTS error,
|
|
6
|
+
DROP COLUMN IF EXISTS processed_at;
|
|
7
|
+
|
|
8
|
+
DROP INDEX IF EXISTS fonderie_events_status_idx;
|
|
9
|
+
|
|
10
|
+
-- Per-consumer delivery tracking
|
|
11
|
+
CREATE TABLE IF NOT EXISTS fonderie_event_consumers (
|
|
12
|
+
event_id UUID NOT NULL REFERENCES fonderie_events(id) ON DELETE CASCADE,
|
|
13
|
+
consumer TEXT NOT NULL,
|
|
14
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
15
|
+
CHECK (status IN ('pending', 'processing', 'processed', 'failed', 'dead')),
|
|
16
|
+
attempts INT NOT NULL DEFAULT 0,
|
|
17
|
+
error TEXT,
|
|
18
|
+
processed_at TIMESTAMPTZ,
|
|
19
|
+
PRIMARY KEY (event_id, consumer)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
-- Partial index — each consumer's poll touches only its own pending rows
|
|
23
|
+
CREATE INDEX IF NOT EXISTS fonderie_event_consumers_poll_idx
|
|
24
|
+
ON fonderie_event_consumers (consumer, status, event_id)
|
|
25
|
+
WHERE status IN ('pending', 'failed');
|
package/package.json
CHANGED