feat: enhance watchlist workflow

This commit is contained in:
2026-06-24 14:43:58 +08:00
parent f8fb09d2a9
commit f1ad5a7d15
7 changed files with 829 additions and 68 deletions

View File

@@ -0,0 +1,21 @@
ALTER TABLE app.watchlist_items
ADD COLUMN IF NOT EXISTS label TEXT NOT NULL DEFAULT 'general',
ADD COLUMN IF NOT EXISTS priority TEXT NOT NULL DEFAULT 'medium',
ADD COLUMN IF NOT EXISTS trigger_operator TEXT NOT NULL DEFAULT 'lte',
ADD COLUMN IF NOT EXISTS trigger_price_psm DOUBLE PRECISION CHECK (trigger_price_psm >= 0),
ADD COLUMN IF NOT EXISTS last_reviewed_at TIMESTAMPTZ;
CREATE TABLE IF NOT EXISTS app.watchlist_events (
event_id BIGSERIAL PRIMARY KEY,
watchlist_item_id BIGINT NOT NULL REFERENCES app.watchlist_items(watchlist_item_id) ON DELETE CASCADE,
event_type TEXT NOT NULL,
summary TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_watchlist_items_label
ON app.watchlist_items(label);
CREATE INDEX IF NOT EXISTS idx_watchlist_items_priority
ON app.watchlist_items(priority);
CREATE INDEX IF NOT EXISTS idx_watchlist_events_item_created
ON app.watchlist_events(watchlist_item_id, created_at DESC);