| 12345678910111213141516171819202122 |
- from app import create_app, db
- from sqlalchemy import text
- app = create_app()
- with app.app_context():
- # Disable foreign key checks
- db.session.execute(text('SET FOREIGN_KEY_CHECKS = 0'))
-
- # Reflect all tables
- db.reflect()
-
- # Drop all tables
- db.drop_all()
- # Recreate all tables
- db.create_all()
-
- # Enable foreign key checks
- db.session.execute(text('SET FOREIGN_KEY_CHECKS = 1'))
-
- print("All tables dropped and recreated.")
|