from sqlalchemy import text from webpass import create_app, db app = create_app() with app.app_context(): print("[-] Disabling Foreign Key Checks...") # This tells MySQL: "Don't complain about connections between tables, just delete them." db.session.execute(text("SET FOREIGN_KEY_CHECKS = 0")) print("[-] Manually dropping ghost 'credential' table...") # Explicitly delete the table that is causing the error db.session.execute(text("DROP TABLE IF EXISTS credential")) print("[-] Dropping all remaining tables...") db.drop_all() print("[-] Creating new schema (User, BiometricDevice, DeadDrop)...") db.create_all() print("[-] Re-enabling Foreign Key Checks...") db.session.execute(text("SET FOREIGN_KEY_CHECKS = 1")) db.session.commit() print("[+] Database reset successful!")