Files
saas_backend/scripts/fix_migration.py
T

28 lines
961 B
Python

import sys
import os
from sqlalchemy import text
# Add parent directory to path so we can import app
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app.config.database import engine
def fix_alembic_version():
target_version = '8acd83604252'
print(f"Attempting to reset alembic_version to {target_version}...")
try:
with engine.begin() as conn:
# Check if table exists
conn.execute(text("DROP TABLE IF EXISTS alembic_version"))
conn.execute(text("CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL)"))
conn.execute(text(f"INSERT INTO alembic_version (version_num) VALUES ('{target_version}')"))
print("Successfully checked/created alembic_version table and inserted target version.")
except Exception as e:
print(f"Error: {e}")
sys.exit(1)
if __name__ == "__main__":
fix_alembic_version()