fix: update logging messages for database operations and version bump
- Changed logging output for PostgreSQL readiness, schema loading, and migration status to a consistent format using [OK], [FAIL], and [WARN]. - Updated application version to 0.8.14 and modified changelog to reflect recent changes, including a fix for co-trainer backfill logic in the database migration. - Enhanced error handling messages for better clarity during migration processes.
This commit is contained in:
1 parent
0c044249d9
commit
e69aca51f6
6 files changed
+51
-36
No files matched your search
+12
-12
@@ -49,14 +49,14 @@ def get_db_connection():
|
||||
password=p["password"],
|
||||
)
|
||||
conn.autocommit = False
|
||||
print(f"✓ Connected to database: {p['dbname']}")
|
||||
print(f"[OK] Connected to database: {p['dbname']}")
|
||||
return conn
|
||||
except psycopg2.OperationalError:
|
||||
if i < max_retries - 1:
|
||||
print(f"Waiting for database... ({i+1}/{max_retries})")
|
||||
time.sleep(2)
|
||||
else:
|
||||
print(f"✗ Failed to connect to database after {max_retries} attempts")
|
||||
print(f"[FAIL] Failed to connect to database after {max_retries} attempts")
|
||||
raise
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def init_migrations_table(conn):
|
||||
"""
|
||||
)
|
||||
conn.commit()
|
||||
print("✓ schema_migrations initialisiert")
|
||||
print("[OK] schema_migrations initialisiert")
|
||||
|
||||
|
||||
_LEADING_DIGITS = re.compile(r"^(\d+)")
|
||||
@@ -190,7 +190,7 @@ def run_migration(conn, migration_name: str, filepath: str) -> bool:
|
||||
if shutil.which("psql"):
|
||||
ok, diag = _run_file_with_psql(filepath)
|
||||
if not ok:
|
||||
print(f" ✗ psql fehlgeschlagen:\n{diag or '(kein Output)'}")
|
||||
print(f" [FAIL] psql fehlgeschlagen:\n{diag or '(kein Output)'}")
|
||||
conn.rollback()
|
||||
return False
|
||||
detail_suffix = "(psql -1)"
|
||||
@@ -199,7 +199,7 @@ def run_migration(conn, migration_name: str, filepath: str) -> bool:
|
||||
with open(filepath, "r", encoding="utf-8") as fh:
|
||||
body = fh.read()
|
||||
except OSError as e:
|
||||
print(f" ✗ kann Datei nicht lesen: {e}")
|
||||
print(f" [FAIL] kann Datei nicht lesen: {e}")
|
||||
conn.rollback()
|
||||
return False
|
||||
|
||||
@@ -207,7 +207,7 @@ def run_migration(conn, migration_name: str, filepath: str) -> bool:
|
||||
with conn.cursor() as cur:
|
||||
if not statements:
|
||||
print(
|
||||
f" ⚠ keine ausführbaren Statements (leer?) — "
|
||||
f" [WARN] keine ausführbaren Statements (leer?) — "
|
||||
f"Eintrag trotzdem: {migration_name}"
|
||||
)
|
||||
else:
|
||||
@@ -217,12 +217,12 @@ def run_migration(conn, migration_name: str, filepath: str) -> bool:
|
||||
|
||||
_record_migration(conn, migration_name)
|
||||
conn.commit()
|
||||
print(f" ✓ {migration_name} erfolgreich {detail_suffix}")
|
||||
print(f" [OK] {migration_name} erfolgreich {detail_suffix}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
conn.rollback()
|
||||
print(f" ✗ {migration_name}: {e}")
|
||||
print(f" [FAIL] {migration_name}: {e}")
|
||||
return False
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ def main():
|
||||
pending = get_pending(conn, migrations_dir)
|
||||
|
||||
if not pending:
|
||||
print("✓ Keine ausstehenden Migrationen — Schema aktuell.")
|
||||
print("[OK] Keine ausstehenden Migrationen — Schema aktuell.")
|
||||
conn.close()
|
||||
return 0
|
||||
|
||||
@@ -262,17 +262,17 @@ def main():
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
if failed:
|
||||
print(f"✗ Abbruch nach: {failed}")
|
||||
print(f"[FAIL] Abbruch nach: {failed}")
|
||||
print(" (Bereits erfolgreiche Dateien dieser Session sind committed.)")
|
||||
print("=" * 60)
|
||||
return 1
|
||||
|
||||
print(f"✓ {len(pending)} Migration(s) angewendet — Schema aktuell.")
|
||||
print(f"[OK] {len(pending)} Migration(s) angewendet — Schema aktuell.")
|
||||
print("=" * 60)
|
||||
return 0
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n✗ Fehler: {e}")
|
||||
print(f"\n[FAIL] Fehler: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user