feat(csv-import): Implement SAVEPOINT handling for vitals baseline import
Deploy Development / deploy (push) Successful in 55s
Build Test / pytest-backend (push) Failing after 1s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 17s

- Updated the CSV import logic to include SAVEPOINT management, allowing for better error handling during the vitals baseline import process.
- Enhanced the SQL migration script to drop existing CHECK constraints related to the 'source' field, ensuring compatibility with the new universal CSV import.
- Incremented DB_SCHEMA_VERSION to "20260409c" to reflect these changes and improve the import process reliability.
This commit is contained in:
Lars committed 2026-04-10 16:11:08 +02:00
1 parent e60976e1cc
commit 5a0c71dd90
5 files changed
+52 -4

No files matched your search

+11 -1
View File
@@ -588,6 +588,9 @@ def _import_vitals_baseline(
continue
iso = d.isoformat()
try:
# Ohne SAVEPOINT: erster fehlgeschlagener INSERT setzt die Xact auf „aborted“,
# alle folgenden Queries + commit() schlagen fehl → generischer 500.
cur.execute("SAVEPOINT vitals_csv_row")
cur.execute(
"""
INSERT INTO vitals_baseline (
@@ -619,8 +622,15 @@ def _import_vitals_baseline(
updated += 1
if result.get("id"):
affected_ids["vitals_baseline"].append(str(result["id"]))
cur.execute("RELEASE SAVEPOINT vitals_csv_row")
except Exception as e:
error_details.append({"row": rows_total, "error": str(e)})
try:
cur.execute("ROLLBACK TO SAVEPOINT vitals_csv_row")
except Exception:
pass
error_details.append(
{"row": rows_total, "error": str(e), "context": "vitals_baseline upsert"},
)
return {
"rows_total": rows_total,