fix: enhance database schema handling for SQLite and PostgreSQL

- Updated schema configuration to set None for SQLite databases.
- Added schema creation logic in the connection wrapper for PostgreSQL.
- Adjusted migration environment to ignore schema for SQLite.
- Fixed unquote parameters in connection tests for consistency.
This commit is contained in:
hobart
2025-05-26 11:33:21 +09:00
parent b203a72c61
commit ea0f54064e
4 changed files with 30 additions and 5 deletions

View File

@@ -77,7 +77,8 @@ def run_migrations_online() -> None:
)
with connectable.connect() as connection:
if target_metadata.schema:
if target_metadata.schema and connection.dialect.name == 'postgresql':
# PostgreSQL에서만 스키마 설정 적용
connection.execute(
text(f"SET search_path TO {target_metadata.schema}, public")
)
@@ -87,6 +88,7 @@ def run_migrations_online() -> None:
version_table_schema=target_metadata.schema,
)
else:
# For SQLite, ignore schema and use default behavior
context.configure(
connection=connection,
target_metadata=target_metadata,