91b4034fee
- 106: Remove AGB duplicates and obsolete templates (terms_of_service DE/EN v1.0, liability clause) — replaced by agb v2.0 - 107: English Terms and Conditions v2 (EU-compliant, same structure as DE version with all IF-blocks) DB now has exactly 2 AGB templates: DE + EN, both v2.0.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
1.8 KiB
SQL
52 lines
1.8 KiB
SQL
-- Migration 106: AGB-Bereinigung — Duplikate und veraltete Templates entfernen
|
|
--
|
|
-- Entfernt:
|
|
-- 1. AGB Duplikat (zweiter Eintrag aus Migration 023, identischer Inhalt wie 090)
|
|
-- 2. terms_of_service DE v1.0.0 (allererste Version aus Migration 018, ersetzt durch agb v2)
|
|
-- 3. terms_of_service EN v1.0.0 (alte englische Version aus Migration 019, wird durch agb EN v2 ersetzt)
|
|
-- 4. clause/liability_clause EN (redundant — AGB v2 § 12 deckt Haftung vollstaendig ab)
|
|
|
|
-- Sicherheitshalber: Nur loeschen wenn die neuen Templates existieren
|
|
DO $$
|
|
BEGIN
|
|
-- Pruefe ob unser AGB v2 existiert
|
|
IF EXISTS (
|
|
SELECT 1 FROM compliance_legal_templates
|
|
WHERE document_type = 'agb' AND version = '2.0.0'
|
|
AND tenant_id = '9282a473-5c95-4b3a-bf78-0ecc0ec71d3e'
|
|
AND length(content) > 20000
|
|
) THEN
|
|
|
|
-- 1. AGB Duplikat loeschen (behalte nur das neueste)
|
|
DELETE FROM compliance_legal_templates
|
|
WHERE document_type = 'agb'
|
|
AND tenant_id = '9282a473-5c95-4b3a-bf78-0ecc0ec71d3e'
|
|
AND id != (
|
|
SELECT id FROM compliance_legal_templates
|
|
WHERE document_type = 'agb'
|
|
AND tenant_id = '9282a473-5c95-4b3a-bf78-0ecc0ec71d3e'
|
|
ORDER BY updated_at DESC
|
|
LIMIT 1
|
|
);
|
|
|
|
RAISE NOTICE 'AGB Duplikat entfernt';
|
|
|
|
-- 2. Veraltete terms_of_service loeschen
|
|
DELETE FROM compliance_legal_templates
|
|
WHERE document_type = 'terms_of_service'
|
|
AND tenant_id = '9282a473-5c95-4b3a-bf78-0ecc0ec71d3e';
|
|
|
|
RAISE NOTICE 'terms_of_service (DE+EN v1) entfernt';
|
|
|
|
-- 3. Liability Clause loeschen (redundant zu AGB § 12)
|
|
DELETE FROM compliance_legal_templates
|
|
WHERE document_type = 'clause'
|
|
AND tenant_id = '9282a473-5c95-4b3a-bf78-0ecc0ec71d3e';
|
|
|
|
RAISE NOTICE 'clause (Liability) entfernt';
|
|
|
|
ELSE
|
|
RAISE NOTICE 'AGB v2 nicht gefunden — keine Bereinigung durchgefuehrt';
|
|
END IF;
|
|
END $$;
|