From 92716b79b6f95f0beab6bb56cc0ff8ecbfea76ae Mon Sep 17 00:00:00 2001 From: h Date: Thu, 8 Oct 2026 05:08:41 +0200 Subject: [PATCH] fix(migrations): alembic autogenerate leaves the taskiq broker tables alone --- .../env.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/template/{{ part_dir }}/{% if database == 'postgres' %}migrations{% endif %}/env.py b/template/{{ part_dir }}/{% if database == 'postgres' %}migrations{% endif %}/env.py index c79960f..490ba5f 100644 --- a/template/{{ part_dir }}/{% if database == 'postgres' %}migrations{% endif %}/env.py +++ b/template/{{ part_dir }}/{% if database == 'postgres' %}migrations{% endif %}/env.py @@ -16,10 +16,15 @@ if config.config_file_name is not None: target_metadata = SQLModel.metadata +def include_name(name: str | None, type_: str, _parents: object) -> bool: + return not (type_ == "table" and name is not None and name.startswith("taskiq_")) + + def run_migrations_offline() -> None: context.configure( url=env.db.connection_url, target_metadata=target_metadata, + include_name=include_name, literal_binds=True, dialect_opts={"paramstyle": "named"}, ) @@ -28,7 +33,11 @@ def run_migrations_offline() -> None: def do_run_migrations(connection: Connection) -> None: - context.configure(connection=connection, target_metadata=target_metadata) + context.configure( + connection=connection, + target_metadata=target_metadata, + include_name=include_name, + ) with context.begin_transaction(): context.run_migrations()