From 041cbff783136369c9746a74123cb9458981c115 Mon Sep 17 00:00:00 2001 From: jessikitty Date: Mon, 2 Feb 2026 21:38:25 +1100 Subject: [PATCH] Add migration for assignment_type column - Creates migration 004_add_assignment_type.py - Adds assignment_type VARCHAR(20) to chores table - Default value: 'any_one' for backward compatibility - Values: 'any_one' (only one needs to complete) or 'all_assigned' (all must complete) - Safe to run on existing database --- backend/migrations/004_add_assignment_type.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 backend/migrations/004_add_assignment_type.py diff --git a/backend/migrations/004_add_assignment_type.py b/backend/migrations/004_add_assignment_type.py new file mode 100644 index 0000000..6a40e1c --- /dev/null +++ b/backend/migrations/004_add_assignment_type.py @@ -0,0 +1,40 @@ +"""Add assignment_type to chores table.""" +import sqlite3 +import sys +from pathlib import Path + +# Add parent directory to path to import from app +sys.path.insert(0, str(Path(__file__).parent.parent)) + +def upgrade(): + """Add assignment_type column to chores table.""" + db_path = Path(__file__).parent.parent / "data" / "family_hub.db" + + print(f"Connecting to database: {db_path}") + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + try: + # Add assignment_type column (default 'any_one' for backward compatibility) + print("Adding assignment_type column to chores table...") + cursor.execute(""" + ALTER TABLE chores + ADD COLUMN assignment_type VARCHAR(20) DEFAULT 'any_one' + """) + + conn.commit() + print("✅ Successfully added assignment_type column") + print(" Values: 'any_one' (only one person needs to complete)") + print(" 'all_assigned' (all assigned people must complete)") + + except sqlite3.OperationalError as e: + if "duplicate column name" in str(e).lower(): + print("⚠️ Column assignment_type already exists, skipping...") + else: + raise + finally: + conn.close() + +if __name__ == "__main__": + upgrade() + print("\n✅ Migration completed!")