Author SHA1 Message Date
Lars 9d15336144 Merge pull request 'Version 9b' (#1) from develop into main
Deploy Production / deploy (push) Failing after 42s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 12s
Reviewed-on: #1
2026-03-19 08:04:01 +01:00
3 changed files with 21 additions and 54 deletions

No files matched your search

+16 -36
View File
@@ -43,11 +43,7 @@ AVATAR_COLORS = ['#1D9E75','#378ADD','#D85A30','#EF9F27','#7F77DD','#D4537E','#6
@app.on_event("startup")
async def startup_event():
"""Run migrations and initialization on startup."""
try:
init_db()
except Exception as e:
print(f"⚠️ init_db() failed (non-fatal): {e}")
# Don't crash on startup - pipeline prompt can be created manually
init_db()
def init_db():
"""Initialize database - Schema is loaded by startup.sh"""
@@ -55,39 +51,23 @@ def init_db():
# This function kept for backwards compatibility
# Ensure "pipeline" master prompt exists
try:
with get_db() as conn:
cur = get_cursor(conn)
# Check if table exists first
with get_db() as conn:
cur = get_cursor(conn)
cur.execute("SELECT COUNT(*) as count FROM ai_prompts WHERE slug='pipeline'")
if cur.fetchone()['count'] == 0:
cur.execute("""
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = 'ai_prompts'
) as table_exists
INSERT INTO ai_prompts (slug, name, description, template, active, sort_order)
VALUES (
'pipeline',
'Mehrstufige Gesamtanalyse',
'Master-Schalter für die gesamte Pipeline. Deaktiviere diese Analyse, um die Pipeline komplett zu verstecken.',
'PIPELINE_MASTER',
true,
-10
)
""")
if not cur.fetchone()['table_exists']:
print("⚠️ ai_prompts table doesn't exist yet - skipping pipeline prompt creation")
return
cur.execute("SELECT COUNT(*) as count FROM ai_prompts WHERE slug='pipeline'")
if cur.fetchone()['count'] == 0:
cur.execute("""
INSERT INTO ai_prompts (slug, name, description, template, active, sort_order)
VALUES (
'pipeline',
'Mehrstufige Gesamtanalyse',
'Master-Schalter für die gesamte Pipeline. Deaktiviere diese Analyse, um die Pipeline komplett zu verstecken.',
'PIPELINE_MASTER',
true,
-10
)
""")
conn.commit()
print("✓ Pipeline master prompt created")
except Exception as e:
print(f"⚠️ Could not create pipeline prompt: {e}")
# Don't fail startup - prompt can be created manually
conn.commit()
print("✓ Pipeline master prompt created")
# ── Helper: get profile_id from header ───────────────────────────────────────
def get_pid(x_profile_id: Optional[str] = Header(default=None)) -> str:
+2 -17
View File
@@ -69,12 +69,6 @@ BOOLEAN_COLUMNS = {
'ai_prompts': ['active'],
}
# Column whitelist for tables that have schema differences
# Only these columns will be migrated (filters out legacy columns)
COLUMN_WHITELIST = {
'ai_insights': ['id', 'profile_id', 'scope', 'content', 'created'],
}
# ================================================================
# CONVERSION HELPERS
@@ -179,17 +173,8 @@ def migrate_table(pg_conn, table: str) -> Dict[str, int]:
# Convert rows
converted_rows = [convert_row(row, table) for row in sqlite_rows]
# Get column names - filter if whitelist exists for this table
if table in COLUMN_WHITELIST:
allowed_columns = COLUMN_WHITELIST[table]
# Filter rows to only include allowed columns
converted_rows = [
{k: v for k, v in row.items() if k in allowed_columns}
for row in converted_rows
]
columns = allowed_columns
else:
columns = list(converted_rows[0].keys())
# Get column names
columns = list(converted_rows[0].keys())
cols_str = ', '.join(columns)
placeholders = ', '.join(['%s'] * len(columns))
+3 -1
View File
@@ -1,7 +1,7 @@
services:
postgres:
image: postgres:16-alpine
container_name: mitai-db-prod
container_name: mitai-db
restart: unless-stopped
environment:
POSTGRES_DB: mitai_prod
@@ -9,6 +9,8 @@ services:
POSTGRES_PASSWORD: ${DB_PASSWORD:-change_me_in_production}
volumes:
- mitai_postgres_data:/var/lib/postgresql/data
ports:
- "127.0.0.1:5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mitai_prod"]
interval: 10s