Files
paliad/internal/db/migrations/031_tier2_fristenrechner_ports.down.sql
m 90b2f935c2 feat(t-paliad-094): Tier 2 Fristenrechner rule ports — damages, cost-appeals, cross-appeal, lay-open, leave/discretion
Per audit recommendations §6.2 (rec 5-9). Ports 14 RoP rules from
youpc's deadline calc into paliad.deadline_rules so they're surfaceable
in the timeline (course-of-proceedings) Fristenrechner mode in addition
to the existing trigger-event mode.

Adds 4 new proceeding types and extends 2 existing trees:

- UPC_DAMAGES (new) — Schadensbemessung (R.137.2, R.139 reply, R.139 rejoin)
- UPC_DISCOVERY (new) — Bucheinsicht (R.142.2, R.142.3 reply, R.142.3 rejoin)
- UPC_COST_APPEAL (new) — Berufung Kostenentscheidung (R.221.1)
- UPC_APP_ORDERS (new) — 15-day order-flavor (R.220.2, R.220.3, R.237 b, R.238.2)
- UPC_INF extended — R.151 chained off inf.decision
- UPC_APP extended — decision-flavor cross-appeal pair (R.237 a, R.238.1)

Total: 14 RoP rules across 5 families. New types appear in the
proceeding-type picker via deadlines.upc_damages / upc_discovery /
upc_cost_appeal / upc_app_orders i18n keys (DE + EN).

Design notes in the migration explain why some rules live in their own
proceeding type (when the legal anchor differs from UPC_INF/UPC_APP's
trigger date) vs being chained off existing rules.
2026-04-30 16:41:38 +02:00

25 lines
1.1 KiB
SQL

-- Reverses 031_tier2_fristenrechner_ports.up.sql.
-- Drops the seeded rules and the new proceeding types in FK-safe order.
-- Remove rules first (parent_id chains within each tree resolve via cascade
-- when the proceeding_type row is dropped, but we delete explicitly so a
-- partial seed is also cleared).
DELETE FROM paliad.deadline_rules
WHERE proceeding_type_id IN (
SELECT id FROM paliad.proceeding_types
WHERE code IN ('UPC_DAMAGES','UPC_DISCOVERY','UPC_COST_APPEAL','UPC_APP_ORDERS')
);
-- The single rule added to UPC_INF and the pair added to UPC_APP.
DELETE FROM paliad.deadline_rules
WHERE proceeding_type_id = (SELECT id FROM paliad.proceeding_types WHERE code = 'UPC_INF')
AND code = 'inf.cost_app';
DELETE FROM paliad.deadline_rules
WHERE proceeding_type_id = (SELECT id FROM paliad.proceeding_types WHERE code = 'UPC_APP')
AND code IN ('app.cross_a', 'app.cross_a_reply');
-- Drop the proceeding types last.
DELETE FROM paliad.proceeding_types
WHERE code IN ('UPC_DAMAGES','UPC_DISCOVERY','UPC_COST_APPEAL','UPC_APP_ORDERS');