Add fixed chapters to market occurrence checklists

This commit is contained in:
gitea_admin committed 2026-09-30 11:59:35 +02:00
1 parent 84a4e6ac63
commit cc534b0ce4
7 files changed
+135 -29

No files matched your search

+2
View File
@@ -20,6 +20,8 @@
16. `db/migrations/0020_include_stock_adjustments_in_balance.sql`
17. `db/migrations/0021_stock_lot_activation_selection.sql`
18. `db/migrations/0022_backfill_stock_lot_activation_selection.sql`
19. `db/migrations/0023_market_management.sql` bis `db/migrations/0034_market_occurrence_checklist.sql`
20. `db/migrations/0035_market_occurrence_checklist_chapters.sql`
## Beispielausfuehrung
@@ -0,0 +1,53 @@
BEGIN;
ALTER TABLE market_occurrence_checklist_item
ADD COLUMN chapter_key TEXT;
DELETE FROM market_occurrence_checklist_item;
UPDATE market_occurrence_checklist
SET comment = NULL,
updated_at = NOW();
ALTER TABLE market_occurrence_checklist_item
ALTER COLUMN chapter_key SET NOT NULL,
ADD CONSTRAINT chk_market_occurrence_checklist_item_chapter
CHECK (chapter_key IN ('products_sales', 'decoration', 'stand_equipment', 'technology'));
INSERT INTO market_occurrence_checklist_item
(occurrence_id, chapter_key, position, label, is_completed)
SELECT checklist.occurrence_id,
defaults.chapter_key,
defaults.position,
defaults.label,
FALSE
FROM market_occurrence_checklist checklist
CROSS JOIN (
VALUES
('products_sales', 1, 'Fläschchen'),
('products_sales', 2, 'Säckchen'),
('products_sales', 3, 'Dunkle Kleber'),
('products_sales', 4, 'Naurua-Kleber'),
('products_sales', 5, 'Anwendungsbeilage'),
('products_sales', 6, 'Flyer Naurua'),
('products_sales', 7, 'Flyer Vitalpilze'),
('products_sales', 8, 'Vitalpilzbuch'),
('products_sales', 9, 'SumUp-Terminal'),
('products_sales', 10, 'Bargeld'),
('decoration', 1, 'Dekoration'),
('decoration', 2, 'Pilze'),
('decoration', 3, 'Blumenvase'),
('decoration', 4, 'Blume'),
('stand_equipment', 1, 'Tisch'),
('stand_equipment', 2, 'Tischtücher'),
('stand_equipment', 3, 'Beleuchtung'),
('stand_equipment', 4, 'Holzklötze'),
('stand_equipment', 5, 'Wagen'),
('stand_equipment', 6, 'Sonnenschirm'),
('stand_equipment', 7, 'Parkkarte/-Marktinformationen'),
('technology', 1, 'Batterie-/Powerbank fürs Handy')
) AS defaults(chapter_key, position, label);
CREATE INDEX idx_market_occurrence_checklist_item_chapter
ON market_occurrence_checklist_item(occurrence_id, chapter_key, position, id);
COMMIT;