import sqlite3
import os

db_path = r'c:\Users\shera\Desktop\FYP Swiftcart\instance\swiftcart_cloud.db'

def migrate():
    if not os.path.exists(db_path):
        print("Database not found!")
        return

    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()

    new_columns = [
        ('show_in_recent', 'BOOLEAN DEFAULT 0'),
        ('show_in_gifts', 'BOOLEAN DEFAULT 0'),
        ('show_in_deals', 'BOOLEAN DEFAULT 0'),
        ('show_in_video', 'BOOLEAN DEFAULT 0')
    ]

    for col_name, col_type in new_columns:
        try:
            cursor.execute(f"ALTER TABLE product ADD COLUMN {col_name} {col_type}")
            print(f"Added column: {col_name}")
        except sqlite3.OperationalError:
            print(f"Column {col_name} already exists.")

    conn.commit()
    conn.close()
    print("Migration complete!")

if __name__ == "__main__":
    migrate()
