● Zion Boggan
repos/Drophawk/backend/migrations/20260101000004_drops.sql
zionboggan.com ↗
16 lines · sql
History for this file →
1
CREATE TABLE drops (
2
    id              BIGSERIAL PRIMARY KEY,
3
    event_id        BIGINT NOT NULL REFERENCES events(id) ON DELETE CASCADE,
4
    drop_type       TEXT NOT NULL CHECK (drop_type IN ('new','status','price','inventory','announcement')),
5
    from_state      JSONB,
6
    to_state        JSONB NOT NULL,
7
    detected_at     TIMESTAMPTZ NOT NULL DEFAULT NOW(),
8
    notified        BOOLEAN NOT NULL DEFAULT FALSE,
9
    notified_at     TIMESTAMPTZ
10
);
11
 
12
CREATE INDEX idx_drops_detected_desc  ON drops(detected_at DESC);
13
CREATE INDEX idx_drops_event          ON drops(event_id);
14
CREATE INDEX idx_drops_type           ON drops(drop_type);
15
CREATE INDEX idx_drops_type_detected  ON drops(drop_type, detected_at DESC);
16