From 112ebdbf7d35e41753441ec5292958cd5869345c Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 27 May 2025 19:07:24 +0000 Subject: [PATCH] Fix SQLAlchemy 2.0 database migration error - Update migrations/env.py to use SQLAlchemy 2.0 compatible syntax - Import text class from sqlalchemy for executing raw SQL - Convert connection.execute() call to use text() for PRAGMA statements - Fix the database migration error for SQLite foreign keys --- migrations/env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index 5af5c1d..12c3006 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -2,7 +2,7 @@ from logging.config import fileConfig import os import sys from alembic import context -from sqlalchemy import engine_from_config, pool +from sqlalchemy import engine_from_config, pool, text # Add the parent directory to sys.path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) @@ -78,7 +78,7 @@ def run_migrations_online(): # For SQLite, enable foreign keys if is_sqlite: - connection.execute("PRAGMA foreign_keys=ON") + connection.execute(text("PRAGMA foreign_keys=ON")) with context.begin_transaction(): context.run_migrations()