fix: Migration 024 - remove problematic FK constraints created_by/updated_by
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled

Goal type definitions are global system entities, not user-specific.
System types seeded in migration cannot have created_by FK.

Changes:
- Remove created_by/updated_by columns from goal_type_definitions
- Update CREATE/UPDATE endpoints to not use these fields
- Migration now runs cleanly on container start
- No manual intervention needed for production deployment
This commit is contained in:
Lars 2026-03-27 07:48:23 +01:00
parent b3cc588293
commit a039a0fad3
2 changed files with 4 additions and 10 deletions

View File

@ -36,9 +36,7 @@ CREATE TABLE IF NOT EXISTS goal_type_definitions (
-- Audit
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
created_by UUID REFERENCES profiles(id) ON DELETE SET NULL,
updated_by UUID REFERENCES profiles(id) ON DELETE SET NULL
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_goal_type_definitions_active ON goal_type_definitions(is_active) WHERE is_active = true;

View File

@ -572,16 +572,14 @@ def create_goal_type_definition(
INSERT INTO goal_type_definitions (
type_key, label_de, label_en, unit, icon, category,
source_table, source_column, aggregation_method,
calculation_formula, description, is_active, is_system,
created_by, updated_by
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
calculation_formula, description, is_active, is_system
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
RETURNING id
""", (
data.type_key, data.label_de, data.label_en, data.unit, data.icon,
data.category, data.source_table, data.source_column,
data.aggregation_method, data.calculation_formula, data.description,
True, False, # is_active=True, is_system=False
pid, pid
True, False # is_active=True, is_system=False
))
goal_type_id = cur.fetchone()['id']
@ -677,8 +675,6 @@ def update_goal_type_definition(
raise HTTPException(status_code=400, detail="Keine Änderungen angegeben")
updates.append("updated_at = NOW()")
updates.append("updated_by = %s")
params.append(pid)
params.append(goal_type_id)
cur.execute(