From 5081785daeb0c481c5f92bd0962275718ff5bfa3 Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Fri, 13 Jun 2025 17:10:00 -0400 Subject: [PATCH] feat: add description field and migration support --- migrate.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 migrate.py diff --git a/migrate.py b/migrate.py new file mode 100644 index 0000000..e2cde99 --- /dev/null +++ b/migrate.py @@ -0,0 +1,33 @@ +import sqlite3 +import sys + + +def migrate_database(): + try: + # Connect to the database + db = sqlite3.connect("pet_pictures.db") + cursor = db.cursor() + + # Check if description column exists + cursor.execute("PRAGMA table_info(pet_pictures)") + columns = [column[1] for column in cursor.fetchall()] + + if "description" not in columns: + print("Adding description column to pet_pictures table...") + cursor.execute("ALTER TABLE pet_pictures ADD COLUMN description TEXT") + db.commit() + print("Migration completed successfully!") + else: + print("Description column already exists. No migration needed.") + + except sqlite3.Error as e: + print(f"An error occurred: {e}") + sys.exit(1) + finally: + if db: + db.close() + + +if __name__ == "__main__": + print("Starting database migration...") + migrate_database()