diff --git a/database.py b/database.py index c6ed79e..f58cc71 100644 --- a/database.py +++ b/database.py @@ -114,11 +114,13 @@ class DatabaseManager: ''') # Photo-Tag linkage table + # linkage_type: INTEGER enum → 0 = single (per-photo add), 1 = bulk (folder-wide add) cursor.execute(''' CREATE TABLE IF NOT EXISTS phototaglinkage ( linkage_id INTEGER PRIMARY KEY AUTOINCREMENT, photo_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, + linkage_type INTEGER NOT NULL DEFAULT 0 CHECK(linkage_type IN (0,1)), created_date DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (photo_id) REFERENCES photos (id), FOREIGN KEY (tag_id) REFERENCES tags (id), @@ -136,23 +138,7 @@ class DatabaseManager: cursor.execute('CREATE INDEX IF NOT EXISTS idx_photos_date_taken ON photos(date_taken)') cursor.execute('CREATE INDEX IF NOT EXISTS idx_photos_date_added ON photos(date_added)') - # Migration: Add date_taken column to existing photos table if it doesn't exist - try: - cursor.execute('ALTER TABLE photos ADD COLUMN date_taken DATE') - if self.verbose >= 1: - print("✅ Added date_taken column to photos table") - except Exception: - # Column already exists, ignore - pass - # Migration: Add date_added column to existing photos table if it doesn't exist - try: - cursor.execute('ALTER TABLE photos ADD COLUMN date_added DATETIME DEFAULT CURRENT_TIMESTAMP') - if self.verbose >= 1: - print("✅ Added date_added column to photos table") - except Exception: - # Column already exists, ignore - pass if self.verbose >= 1: print(f"✅ Database initialized: {self.db_path}")