Files
TimeTracker/docker/migrate-add-tasks.py
Dries Peeters 98728691ef feat: Add comprehensive Task Management system with automatic database migration
- Add Task model with full CRUD operations, status tracking, and priority management
- Integrate tasks with existing projects and time entries via foreign key relationships
- Create new Flask routes (/tasks) with admin and user role-based access control
- Implement task status transitions (pending → in_progress → completed → cancelled)
- Add task filtering by status, priority, assignee, and project
- Create responsive Jinja2 templates for task listing, creation, editing, and viewing
- Integrate task selection in timer and manual time entry forms
- Add task management to project dashboards and navigation menus
- Implement automatic database migration system for seamless deployment
- Create migration scripts to add missing tables and columns
- Update startup script to detect and run migrations automatically
- Add comprehensive error handling and validation
- Include full documentation (TASK_MANAGEMENT_README.md)
- Update project structure and main README with new feature details

Database Changes:
- New 'tasks' table with indexes for performance
- Add 'task_id' column to 'time_entries' table
- Automatic migration detection and execution

Technical Implementation:
- SQLAlchemy relationships with proper backrefs and cascading
- Flask-Login integration for role-based access
- Bootstrap 5 responsive UI components
- Font Awesome icons for visual enhancement
- Comprehensive test coverage and error handling

This feature enables users to break down projects into manageable tasks,
track progress, assign work, and maintain better project organization.
2025-08-29 11:48:47 +02:00

38 lines
1.0 KiB
Python

#!/usr/bin/env python3
"""
Database migration script to add Task Management feature
"""
import sys
import os
# Add the parent directory to the path so we can import the app
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app import create_app, db
from app.models import Task
def migrate_database():
"""Run the database migration"""
app = create_app()
with app.app_context():
print("Starting Task Management migration...")
try:
# Use the app's built-in migration function
from app import migrate_task_management_tables
migrate_task_management_tables()
print("\nMigration completed successfully!")
print("Task Management feature is now available.")
return True
except Exception as e:
print(f"✗ Migration failed: {e}")
return False
if __name__ == '__main__':
success = migrate_database()
sys.exit(0 if success else 1)