feat(discovery): seed 24-month DACH bucket window
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- Do not delete rows on rollback — `last_queried_at` and `last_error` may carry
|
||||
-- operational state. The table itself is dropped by 000011's down migration.
|
||||
SELECT 1;
|
||||
38
backend/migrations/000014_seed_discovery_buckets.up.sql
Normal file
38
backend/migrations/000014_seed_discovery_buckets.up.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- Seed buckets for the 24-month window starting current month.
|
||||
WITH regions(land, region) AS (
|
||||
VALUES
|
||||
('Deutschland', 'Baden-Württemberg'),
|
||||
('Deutschland', 'Bayern'),
|
||||
('Deutschland', 'Berlin'),
|
||||
('Deutschland', 'Brandenburg'),
|
||||
('Deutschland', 'Bremen'),
|
||||
('Deutschland', 'Hamburg'),
|
||||
('Deutschland', 'Hessen'),
|
||||
('Deutschland', 'Mecklenburg-Vorpommern'),
|
||||
('Deutschland', 'Niedersachsen'),
|
||||
('Deutschland', 'Nordrhein-Westfalen'),
|
||||
('Deutschland', 'Rheinland-Pfalz'),
|
||||
('Deutschland', 'Saarland'),
|
||||
('Deutschland', 'Sachsen'),
|
||||
('Deutschland', 'Sachsen-Anhalt'),
|
||||
('Deutschland', 'Schleswig-Holstein'),
|
||||
('Deutschland', 'Thüringen'),
|
||||
('Österreich', 'Burgenland'),
|
||||
('Österreich', 'Kärnten'),
|
||||
('Österreich', 'Niederösterreich'),
|
||||
('Österreich', 'Oberösterreich'),
|
||||
('Österreich', 'Salzburg'),
|
||||
('Österreich', 'Steiermark'),
|
||||
('Österreich', 'Tirol'),
|
||||
('Österreich', 'Vorarlberg'),
|
||||
('Österreich', 'Wien'),
|
||||
('Schweiz', 'Schweiz')
|
||||
),
|
||||
months AS (
|
||||
SELECT to_char(date_trunc('month', now())::date + (n || ' month')::interval, 'YYYY-MM') AS year_month
|
||||
FROM generate_series(0, 23) AS n
|
||||
)
|
||||
INSERT INTO discovery_buckets (land, region, year_month)
|
||||
SELECT r.land, r.region, m.year_month
|
||||
FROM regions r CROSS JOIN months m
|
||||
ON CONFLICT (land, region, year_month) DO NOTHING;
|
||||
Reference in New Issue
Block a user