- Implemented Pomodoro timer in the app, allowing users to start, pause, and stop sessions. - Added context for managing Pomodoro state and actions. - Integrated time logging for completed sessions to track productivity. - Enhanced project settings to include time goals and Pomodoro settings. - Created migration scripts to update the database schema for new project fields and time logs. - Updated UI components to display Pomodoro controls and project time summaries. - Added category filtering for projects in the project list view.
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""
|
|
Migration script to add time goals, category, and pomodoro settings to projects table.
|
|
Run this once if you have an existing database.
|
|
"""
|
|
import sqlite3
|
|
import os
|
|
|
|
db_path = os.path.join(os.path.dirname(__file__), 'bit.db')
|
|
|
|
if not os.path.exists(db_path):
|
|
print("No migration needed - new database will be created with the correct schema.")
|
|
exit(0)
|
|
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
cursor.execute("PRAGMA table_info(projects)")
|
|
columns = [column[1] for column in cursor.fetchall()]
|
|
|
|
new_columns = [
|
|
("category", "TEXT DEFAULT NULL"),
|
|
("weekly_hours_goal", "INTEGER DEFAULT NULL"),
|
|
("total_hours_goal", "INTEGER DEFAULT NULL"),
|
|
("pomodoro_work_minutes", "INTEGER DEFAULT 25"),
|
|
("pomodoro_break_minutes", "INTEGER DEFAULT 5"),
|
|
]
|
|
|
|
for col_name, col_def in new_columns:
|
|
if col_name in columns:
|
|
print(f"Column '{col_name}' already exists. Skipping.")
|
|
else:
|
|
cursor.execute(f"ALTER TABLE projects ADD COLUMN {col_name} {col_def}")
|
|
print(f"Successfully added '{col_name}'.")
|
|
|
|
conn.commit()
|
|
print("Migration complete.")
|
|
except Exception as e:
|
|
print(f"Error during migration: {e}")
|
|
conn.rollback()
|
|
finally:
|
|
conn.close()
|