mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-28 23:49:30 -06:00
Major Features: - Add project costs feature with full CRUD operations - Implement toast notification system for better user feedback - Enhance analytics dashboard with improved visualizations - Add OIDC authentication improvements and debug tools Improvements: - Enhance reports with new filtering and export capabilities - Update command palette with additional shortcuts - Improve mobile responsiveness across all pages - Refactor UI components for consistency Removals: - Remove license server integration and related dependencies - Clean up unused license-related templates and utilities Technical Changes: - Add new migration 018 for project_costs table - Update models: Project, Settings, User with new relationships - Refactor routes: admin, analytics, auth, invoices, projects, reports - Update static assets: CSS improvements, new JS modules - Enhance templates: analytics, admin, projects, reports Documentation: - Add comprehensive documentation for project costs feature - Document toast notification system with visual guides - Update README with new feature descriptions - Add migration instructions and quick start guides - Document OIDC improvements and Kanban enhancements Files Changed: - Modified: 56 files (core app, models, routes, templates, static assets) - Deleted: 6 files (license server integration) - Added: 28 files (new features, documentation, migrations)
98 lines
3.2 KiB
Python
98 lines
3.2 KiB
Python
"""
|
|
Migration script to add allow_analytics field to settings table
|
|
Run this script to add the new privacy setting field
|
|
"""
|
|
|
|
import sqlite3
|
|
import os
|
|
from datetime import datetime
|
|
|
|
def migrate_sqlite():
|
|
"""Migrate SQLite database"""
|
|
db_path = 'instance/timetracker.db'
|
|
if not os.path.exists(db_path):
|
|
print(f"SQLite database not found at {db_path}")
|
|
return False
|
|
|
|
try:
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# Check if column already exists
|
|
cursor.execute("PRAGMA table_info(settings)")
|
|
columns = [column[1] for column in cursor.fetchall()]
|
|
|
|
if 'allow_analytics' not in columns:
|
|
# Add the new column
|
|
cursor.execute("ALTER TABLE settings ADD COLUMN allow_analytics BOOLEAN DEFAULT 1")
|
|
conn.commit()
|
|
print("✓ Added allow_analytics column to SQLite settings table")
|
|
else:
|
|
print("✓ allow_analytics column already exists in SQLite settings table")
|
|
|
|
conn.close()
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"Error migrating SQLite database: {e}")
|
|
return False
|
|
|
|
def migrate_postgres():
|
|
"""Migrate PostgreSQL database"""
|
|
try:
|
|
import psycopg2
|
|
from psycopg2.extras import RealDictCursor
|
|
|
|
# Get database URL from environment or use default
|
|
db_url = os.getenv('DATABASE_URL', 'postgresql://timetracker:timetracker@localhost:5432/timetracker')
|
|
|
|
conn = psycopg2.connect(db_url)
|
|
cursor = conn.cursor()
|
|
|
|
# Check if column already exists
|
|
cursor.execute("""
|
|
SELECT column_name
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'settings' AND column_name = 'allow_analytics'
|
|
""")
|
|
|
|
if not cursor.fetchone():
|
|
# Add the new column
|
|
cursor.execute("ALTER TABLE settings ADD COLUMN allow_analytics BOOLEAN DEFAULT TRUE")
|
|
conn.commit()
|
|
print("✓ Added allow_analytics column to PostgreSQL settings table")
|
|
else:
|
|
print("✓ allow_analytics column already exists in PostgreSQL settings table")
|
|
|
|
conn.close()
|
|
return True
|
|
|
|
except ImportError:
|
|
print("PostgreSQL driver not available - skipping PostgreSQL migration")
|
|
return False
|
|
except Exception as e:
|
|
print(f"Error migrating PostgreSQL database: {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""Run the migration"""
|
|
print("Starting migration: Adding allow_analytics field to settings table")
|
|
print("=" * 60)
|
|
|
|
# Try SQLite first
|
|
sqlite_success = migrate_sqlite()
|
|
|
|
# Try PostgreSQL
|
|
postgres_success = migrate_postgres()
|
|
|
|
if sqlite_success or postgres_success:
|
|
print("\n✓ Migration completed successfully!")
|
|
print("\nThe new 'allow_analytics' setting has been added to your settings table.")
|
|
print("Users can now control whether system information is shared for analytics.")
|
|
else:
|
|
print("\n✗ Migration failed for all database types.")
|
|
print("Please check your database connection and try again.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|