feat(discovery): seed 24-month DACH bucket window

This commit is contained in:
2026-04-18 07:20:32 +02:00
parent fa15810dbb
commit 174635e241
2 changed files with 41 additions and 0 deletions

View File

@@ -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;

View 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;