From f0357ee4739ad0987d0bd9f9fab7ee04858f6085 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Wed, 4 Mar 2026 14:45:50 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20apply=5Ftemplates=5F023.py=20=E2=80=94?= =?UTF-8?q?=20placeholders=20als=20JSONB=20+=20version/status=20Felder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - json.dumps() für jsonb-Spalte statt Python-Liste - CAST(:placeholders AS jsonb) in SQL - version='1.0' + status='active' hinzugefügt Co-Authored-By: Claude Sonnet 4.6 --- scripts/apply_templates_023.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/apply_templates_023.py b/scripts/apply_templates_023.py index 87d79e8..227568d 100644 --- a/scripts/apply_templates_023.py +++ b/scripts/apply_templates_023.py @@ -13,7 +13,9 @@ Usage: docker exec bp-compliance-backend python3 /tmp/apply_templates_023.py """ +import json import os +import re import sys import uuid @@ -640,8 +642,7 @@ def main() -> None: print(f'[SKIP] Bereits vorhanden: {t["title"]}') continue - # Extract placeholders from content - import re + # Extract placeholders from content (jsonb column → pass as JSON string) placeholders = sorted(set(re.findall(r'\{\{[A-Z_]+\}\}', t['content']))) new_id = str(uuid.uuid4()) @@ -651,12 +652,12 @@ def main() -> None: (id, title, document_type, language, jurisdiction, content, description, license_id, license_name, source_name, is_complete_document, attribution_required, - placeholders, created_at, updated_at) + placeholders, version, status, created_at, updated_at) VALUES (:id, :title, :document_type, :language, :jurisdiction, :content, :description, :license_id, :license_name, :source_name, :is_complete_document, :attribution_required, - :placeholders, NOW(), NOW()) + CAST(:placeholders AS jsonb), :version, :status, NOW(), NOW()) '''), { 'id': new_id, @@ -671,7 +672,9 @@ def main() -> None: 'source_name': t['source_name'], 'is_complete_document': t['is_complete_document'], 'attribution_required': t['attribution_required'], - 'placeholders': placeholders, + 'placeholders': json.dumps(placeholders), + 'version': '1.0', + 'status': 'active', } ) print(f'[OK] {t["title"]} ({t["document_type"]}/{t["language"]}) — {len(placeholders)} Platzhalter')