feat(discovery): add discovered_markets queue table migration
This commit is contained in:
1
backend/migrations/000012_discovered_markets.down.sql
Normal file
1
backend/migrations/000012_discovered_markets.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS discovered_markets;
|
||||
30
backend/migrations/000012_discovered_markets.up.sql
Normal file
30
backend/migrations/000012_discovered_markets.up.sql
Normal 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';
|
||||
Reference in New Issue
Block a user