From f4232d862e879c5f3c70daae5f8cec4c03a91812 Mon Sep 17 00:00:00 2001 From: Ash Berlin-Taylor Date: Tue, 1 Oct 2019 10:49:01 +0100 Subject: [PATCH] [AIRFLOW-XXX] Ignore FAB's db tables when auto-generating migrations --- airflow/migrations/env.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/airflow/migrations/env.py b/airflow/migrations/env.py index e22e7c7b7ce1d..1209539db6c2e 100644 --- a/airflow/migrations/env.py +++ b/airflow/migrations/env.py @@ -23,6 +23,16 @@ from airflow import settings from airflow import models + +def include_object(_, name, type_, *args): + """Filter objects for autogenerating revisions""" + # Ignore _anything_ to do with Flask AppBuilder's tables + if type_ == "table" and name.startswith("ab_"): + return False + else: + return True + + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -80,6 +90,7 @@ def run_migrations_online(): transaction_per_migration=True, target_metadata=target_metadata, compare_type=COMPARE_TYPE, + include_object=include_object, ) with context.begin_transaction():