""" Migration: Add allocated and allocated_to_project_id columns to roster table. Run once: python backend/migrate_add_allocated.py """ import sqlite3 import os DB_PATH = os.path.join(os.path.dirname(__file__), '..', 'data', 'seismo_fleet.db') def run(): conn = sqlite3.connect(DB_PATH) cur = conn.cursor() # Check existing columns cur.execute("PRAGMA table_info(roster)") cols = {row[1] for row in cur.fetchall()} if 'allocated' not in cols: cur.execute("ALTER TABLE roster ADD COLUMN allocated BOOLEAN DEFAULT 0 NOT NULL") print("Added column: allocated") else: print("Column already exists: allocated") if 'allocated_to_project_id' not in cols: cur.execute("ALTER TABLE roster ADD COLUMN allocated_to_project_id VARCHAR") print("Added column: allocated_to_project_id") else: print("Column already exists: allocated_to_project_id") conn.commit() conn.close() print("Migration complete.") if __name__ == '__main__': run()