Files
TimeTracker/docker/fix-column-name-mismatch.py
Dries Peeters d230a41e8a feat: enhance web interface layout and fix logo import circular dependency
- Improve web interface layout for better user-friendliness and mobile responsiveness
  * Update CSS variables for consistent spacing and component sizing
  * Enhance card layouts with improved padding, borders, and shadows
  * Optimize button and form element dimensions for better touch targets
  * Add hover effects and animations for improved user interaction
  * Implement responsive grid system with mobile-first approach

- Refactor mobile JavaScript to prevent duplicate initialization
  * Consolidate mobile enhancements into dedicated utility classes
  * Add initialization guards to prevent double loading
  * Implement MobileUtils and MobileNavigation classes
  * Remove duplicate event listeners and mobile enhancements

- Fix circular import issue in logo handling
  * Replace problematic 'from app import app' with Flask's current_app
  * Add error handling for cases where current_app is unavailable
  * Improve logo path resolution with fallback mechanisms
  * Fix settings model to use proper Flask context

- Clean up template code and remove duplication
  * Remove duplicate mobile enhancements from base template
  * Clean up dashboard template JavaScript
  * Centralize all mobile functionality in mobile.js
  * Add proper error handling and debugging

- Update CSS variables and spacing system
  * Introduce --section-spacing and --card-spacing variables
  * Add mobile-specific spacing variables
  * Improve border-radius and shadow consistency
  * Enhance typography and visual hierarchy

This commit resolves the double loading issue and logo import errors while
significantly improving the overall user experience and mobile responsiveness
of the web interface.
2025-08-30 10:09:06 +02:00

75 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""
Fix script to resolve column name mismatch in settings table
The database has 'company_logo_path' but the application expects 'company_logo_filename'
"""
import os
import sys
from sqlalchemy import create_engine, text
def main():
"""Fix the column name mismatch in settings table"""
url = os.getenv("DATABASE_URL", "postgresql+psycopg2://timetracker:timetracker@db:5432/timetracker")
print(f"Connecting to database: {url}")
try:
engine = create_engine(url, pool_pre_ping=True)
with engine.connect() as conn:
print("Checking current table structure...")
# Check what columns currently exist
result = conn.execute(text("""
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'settings'
ORDER BY column_name;
"""))
columns = [row[0] for row in result]
print(f"Current columns: {columns}")
# Check if we have the old column name
if 'company_logo_path' in columns and 'company_logo_filename' not in columns:
print("Found 'company_logo_path' column, need to rename it to 'company_logo_filename'")
# Rename the column
conn.execute(text("ALTER TABLE settings RENAME COLUMN company_logo_path TO company_logo_filename;"))
print("✓ Renamed company_logo_path to company_logo_filename")
elif 'company_logo_filename' in columns:
print("✓ company_logo_filename column already exists")
else:
print("Neither column exists, adding company_logo_filename")
conn.execute(text("ALTER TABLE settings ADD COLUMN company_logo_filename VARCHAR(255) DEFAULT '' NOT NULL;"))
print("✓ Added company_logo_filename column")
# Verify the fix
result = conn.execute(text("""
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'settings'
ORDER BY column_name;
"""))
columns_after = [row[0] for row in result]
print(f"Columns after fix: {columns_after}")
if 'company_logo_filename' in columns_after:
print("✓ Column name mismatch fixed successfully!")
else:
print("✗ Failed to fix column name mismatch")
sys.exit(1)
conn.commit()
except Exception as e:
print(f"✗ Error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()