Add comprehensive documentation for LeagueLedger

- Created architecture overview in development/architecture.md
- Added installation guide in getting-started/installation.md
- Developed user guide with detailed instructions in user-guide/overview.md, user-guide/teams.md, user-guide/qr-codes.md
- Implemented social login setup documentation in social_login_setup.md
- Updated index.md to include links to new documentation sections
- Configured mkdocs.yml for site structure and theme
- Added requirements.txt for documentation dependencies
This commit is contained in:
Christian Krakau-Louis
2025-04-15 12:32:03 +02:00
parent 7323c12168
commit 6306abf6d9
26 changed files with 3350 additions and 132 deletions
+86 -1
View File
@@ -1,4 +1,4 @@
from sqlalchemy import text, inspect
from sqlalchemy import text, inspect, Column, String, JSON, MetaData, Table
from .db import engine
def table_exists(conn, table_name):
@@ -90,3 +90,88 @@ def apply_migrations():
except Exception as e:
print(f"Error applying migrations: {str(e)}")
def run_migrations(engine):
"""
Run database migrations that can't be handled by SQLAlchemy's create_all()
"""
# Create a MetaData object
metadata = MetaData()
metadata.bind = engine
connection = engine.connect()
try:
print("Running migrations...")
# Check if the columns already exist before adding them
# Add additional_oauth_providers column if it doesn't exist
add_oauth_providers_column(connection)
# Add first_name and last_name columns if they don't exist
add_name_columns(connection)
print("Migrations completed successfully")
except Exception as e:
print(f"Error during migrations: {str(e)}")
finally:
connection.close()
def add_oauth_providers_column(connection):
"""Add additional_oauth_providers column to users table"""
try:
# Use database-agnostic way to check if column exists
inspector = inspect(engine)
columns = [col['name'] for col in inspector.get_columns('users')]
if 'additional_oauth_providers' not in columns:
print("Adding additional_oauth_providers column to users table")
# Add column with database-specific syntax
if engine.name == 'sqlite':
connection.execute(text("""
ALTER TABLE users
ADD COLUMN additional_oauth_providers JSON
"""))
else: # MySQL
connection.execute(text("""
ALTER TABLE users
ADD COLUMN additional_oauth_providers JSON NULL
"""))
connection.commit()
else:
print("Column additional_oauth_providers already exists")
except Exception as e:
print(f"Error adding additional_oauth_providers column: {str(e)}")
def add_name_columns(connection):
"""Add first_name and last_name columns to users table"""
try:
# Use database-agnostic way to check if columns exist
inspector = inspect(engine)
columns = [col['name'] for col in inspector.get_columns('users')]
# Add first_name if needed
if 'first_name' not in columns:
print("Adding first_name column to users table")
connection.execute(text("""
ALTER TABLE users
ADD COLUMN first_name VARCHAR(50) NULL
"""))
connection.commit()
else:
print("Column first_name already exists")
# Add last_name if needed
if 'last_name' not in columns:
print("Adding last_name column to users table")
connection.execute(text("""
ALTER TABLE users
ADD COLUMN last_name VARCHAR(50) NULL
"""))
connection.commit()
else:
print("Column last_name already exists")
except Exception as e:
print(f"Error adding name columns: {str(e)}")