"feat: Update database schema documentation and related files"

This commit is contained in:
Till Tomczak 2025-05-29 12:10:23 +02:00
parent 96f9af232a
commit 6e154f7196
4 changed files with 26 additions and 13 deletions

View File

@ -0,0 +1 @@

Binary file not shown.

View File

@ -0,0 +1 @@

View File

@ -13,6 +13,7 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from models import init_db, get_cached_session, GuestRequest, UserPermission, Notification, User
from utils.logging_config import get_logger
from config.settings import DATABASE_PATH
logger = get_logger("migrate")
@ -24,19 +25,29 @@ def column_exists(cursor, table_name, column_name):
def get_database_path():
"""Ermittelt den Pfad zur Datenbankdatei."""
db_path = os.path.join('database', 'app.db')
if not os.path.exists(db_path):
# Fallback für alternative Pfade
alternative_paths = [
'app.db',
'../database/app.db',
'./database/app.db'
]
for path in alternative_paths:
if os.path.exists(path):
db_path = path
break
return db_path
# Verwende den korrekten Datenbankpfad aus der Konfiguration
if os.path.exists(DATABASE_PATH):
return DATABASE_PATH
# Fallback für alternative Pfade mit korrektem Dateinamen
alternative_paths = [
os.path.join('database', 'myp.db'),
'myp.db',
'../database/myp.db',
'./database/myp.db',
# Legacy-Pfade für Rückwärtskompatibilität
os.path.join('database', 'app.db'),
'app.db',
'../database/app.db',
'./database/app.db'
]
for path in alternative_paths:
if os.path.exists(path):
return path
# Falls keine Datei gefunden wird, verwende den konfigurierten Pfad
return DATABASE_PATH
def migrate_guest_requests_table():
"""Migriert die guest_requests Tabelle für neue Spalten."""