fix(api): commit after create_all in alembic env.py
SQLAlchemy 2.0 removed implicit autocommit; without an explicit connection.commit() DDL changes from create_all() are rolled back when the connection closes, leaving fresh databases without tables. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -53,6 +53,7 @@ def run_migrations_online() -> None:
|
|||||||
# checkfirst=True ensures this is a no-op on existing databases.
|
# checkfirst=True ensures this is a no-op on existing databases.
|
||||||
try:
|
try:
|
||||||
Base.metadata.create_all(bind=connection, checkfirst=True)
|
Base.metadata.create_all(bind=connection, checkfirst=True)
|
||||||
|
connection.commit()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger("alembic.env").warning(
|
logging.getLogger("alembic.env").warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user