mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-30 09:40:50 +02:00
ignore kombu tables used by celery in alembic (#2261)
This commit is contained in:
@ -8,6 +8,7 @@ from sqlalchemy import pool
|
|||||||
from sqlalchemy.engine import Connection
|
from sqlalchemy.engine import Connection
|
||||||
from sqlalchemy.ext.asyncio import create_async_engine
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||||||
from celery.backends.database.session import ResultModelBase # type: ignore
|
from celery.backends.database.session import ResultModelBase # type: ignore
|
||||||
|
from sqlalchemy.schema import SchemaItem
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# 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")
|
# my_important_option = config.get_main_option("my_important_option")
|
||||||
# ... etc.
|
# ... 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:
|
def run_migrations_offline() -> None:
|
||||||
"""Run migrations in 'offline' mode.
|
"""Run migrations in 'offline' mode.
|
||||||
@ -55,7 +70,11 @@ def run_migrations_offline() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> 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():
|
with context.begin_transaction():
|
||||||
context.run_migrations()
|
context.run_migrations()
|
||||||
|
Reference in New Issue
Block a user