migrate_carousel_text.py 653 B

123456789101112131415161718192021
  1. from app import create_app, db
  2. from sqlalchemy import text
  3. app = create_app()
  4. with app.app_context():
  5. print("Adding text columns to carousel table...")
  6. try:
  7. db.session.execute(text('ALTER TABLE carousel ADD COLUMN tag_text VARCHAR(64);'))
  8. print("Added tag_text")
  9. except Exception as e:
  10. print("tag_text might already exist:", e)
  11. try:
  12. db.session.execute(text('ALTER TABLE carousel ADD COLUMN title_content TEXT;'))
  13. print("Added title_content")
  14. except Exception as e:
  15. print("title_content might already exist:", e)
  16. db.session.commit()
  17. print("Migration completed.")