diff --git a/backend/alembic/env.py b/backend/alembic/env.py index 8a944689d..8c028202b 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -8,6 +8,7 @@ from sqlalchemy import pool from sqlalchemy.engine import Connection from sqlalchemy.ext.asyncio import create_async_engine from celery.backends.database.session import ResultModelBase # type: ignore +from sqlalchemy.schema import SchemaItem # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -29,6 +30,20 @@ target_metadata = [Base.metadata, ResultModelBase.metadata] # my_important_option = config.get_main_option("my_important_option") # ... etc. +EXCLUDE_TABLES = {"kombu_queue", "kombu_message"} + + +def include_object( + object: SchemaItem, + name: str, + type_: str, + reflected: bool, + compare_to: SchemaItem | None, +) -> bool: + if type_ == "table" and name in EXCLUDE_TABLES: + return False + return True + def run_migrations_offline() -> None: """Run migrations in 'offline' mode. @@ -55,7 +70,11 @@ def run_migrations_offline() -> None: def do_run_migrations(connection: Connection) -> None: - context.configure(connection=connection, target_metadata=target_metadata) # type: ignore + context.configure( + connection=connection, + target_metadata=target_metadata, # type: ignore + include_object=include_object, + ) # type: ignore with context.begin_transaction(): context.run_migrations()