from database import engine
from sqlalchemy import text

def migrate():
    print("Starting migration...")
    with engine.connect() as conn:
        try:
            # Add end_chapter
            try:
                conn.execute(text("ALTER TABLE daily_bread ADD COLUMN end_chapter INT NULL;"))
                print("Added column: end_chapter")
            except Exception as e:
                print(f"Skipping end_chapter (maybe exists): {e}")

            # Add end_verse
            try:
                conn.execute(text("ALTER TABLE daily_bread ADD COLUMN end_verse VARCHAR(50) NULL;"))
                print("Added column: end_verse")
            except Exception as e:
                print(f"Skipping end_verse (maybe exists): {e}")
                
            conn.commit()
            print("Migration completed successfully!")
        except Exception as e:
            print(f"Migration error: {e}")

if __name__ == "__main__":
    migrate()
