f547d05478
Adds a Schedule tab (Kitsu-style production schedule) under each project: tasks grouped by type with drag-to-reschedule bars, Day/Week/ Month zoom, manual date-range control, weekend shading, a frozen task column, and a two-tier month/date axis header. Requires a new start_date field on Task (start_date was previously missing; only deadline existed) and shadcn DatePicker inputs replace native date inputs on the Schedule toolbar and TaskDetailPanel's Start Date/ Deadline fields. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Migration script to add the start_date column to the tasks table.
|
|
|
|
Usage:
|
|
python migrate_task_start_date.py
|
|
"""
|
|
|
|
import sqlite3
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def get_database_path():
|
|
"""Get the database path, trying multiple possible locations."""
|
|
possible_paths = [
|
|
"vfx_project_management.db", # Primary database
|
|
"database.db",
|
|
"../vfx_project_management.db"
|
|
]
|
|
|
|
for path in possible_paths:
|
|
if Path(path).exists():
|
|
return path
|
|
|
|
return "vfx_project_management.db"
|
|
|
|
|
|
def check_column_exists(cursor, table_name, column_name):
|
|
"""Check if a column exists in a table."""
|
|
cursor.execute(f"PRAGMA table_info({table_name})")
|
|
columns = [column[1] for column in cursor.fetchall()]
|
|
return column_name in columns
|
|
|
|
|
|
def migrate_database():
|
|
"""Add start_date column to the tasks table."""
|
|
db_path = get_database_path()
|
|
print(f"Using database: {db_path}")
|
|
|
|
conn = None
|
|
try:
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tasks'")
|
|
if not cursor.fetchone():
|
|
print("Tasks table not found. Creating new database schema...")
|
|
conn.close()
|
|
return
|
|
|
|
if check_column_exists(cursor, "tasks", "start_date"):
|
|
print("Column start_date already exists, skipping...")
|
|
else:
|
|
print("Adding column: start_date")
|
|
cursor.execute("ALTER TABLE tasks ADD COLUMN start_date DATE")
|
|
|
|
conn.commit()
|
|
|
|
cursor.execute("SELECT COUNT(*) FROM tasks")
|
|
task_count = cursor.fetchone()[0]
|
|
print(f"Migration completed successfully! {task_count} tasks unaffected (column defaults to NULL).")
|
|
|
|
except sqlite3.Error as e:
|
|
print(f"Database error: {e}")
|
|
if conn:
|
|
conn.rollback()
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"Unexpected error: {e}")
|
|
if conn:
|
|
conn.rollback()
|
|
sys.exit(1)
|
|
finally:
|
|
if conn:
|
|
conn.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("VFX Project Management - Task Start Date Migration")
|
|
print("=" * 60)
|
|
|
|
migrate_database()
|
|
|
|
print("\nMigration completed successfully!")
|