feat(discovery): add discovered_markets queue table migration

This commit is contained in:
2026-04-18 07:14:19 +02:00
parent d0b2ad6362
commit cddd0196c0
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS discovered_markets;

View File

@@ -0,0 +1,30 @@
CREATE TABLE discovered_markets (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
bucket_id uuid NOT NULL REFERENCES discovery_buckets(id) ON DELETE CASCADE,
markt_name text NOT NULL,
stadt text NOT NULL,
bundesland text,
land text NOT NULL,
start_datum date,
end_datum date,
website text,
quellen text[] NOT NULL DEFAULT '{}',
extraktion text,
hinweis text,
name_normalized text NOT NULL,
matched_series_id uuid REFERENCES market_series(id) ON DELETE SET NULL,
status text NOT NULL DEFAULT 'pending'
CHECK (status IN ('pending', 'accepted', 'rejected')),
discovered_at timestamptz NOT NULL DEFAULT now(),
reviewed_at timestamptz,
reviewed_by uuid REFERENCES users(id) ON DELETE SET NULL,
created_edition_id uuid REFERENCES market_editions(id) ON DELETE SET NULL
);
CREATE INDEX idx_discovered_markets_pending
ON discovered_markets (status, discovered_at)
WHERE status = 'pending';
CREATE INDEX idx_discovered_markets_dedup
ON discovered_markets (name_normalized, stadt, start_datum)
WHERE status = 'pending';