From 5a85bec54085af93e6674bb401745bfc07829765 Mon Sep 17 00:00:00 2001 From: Daniel Grams Date: Tue, 2 May 2023 22:34:08 +0200 Subject: [PATCH] Delete account #456 --- migrations/env.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/migrations/env.py b/migrations/env.py index c6a184c..b4ce7fa 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -56,6 +56,18 @@ exclude_tables = exclude_items_from_config(config_exclude_section, "tables") exclude_indexes = exclude_items_from_config(config_exclude_section, "indexes") +def include_name(name, type_, parent_names): + if type_ == "schema": + return not name + + if type_ == "table": + metadata = get_metadata() + if metadata: + return name in metadata.tables + + return True + + def include_object(object, name, type_, reflected, compare_to): if type_ == "table" and name in exclude_tables: return False @@ -83,6 +95,8 @@ def run_migrations_offline(): target_metadata=get_metadata(), literal_binds=True, include_object=include_object, + include_name=include_name, + include_schemas=True, ) with context.begin_transaction(): @@ -115,6 +129,8 @@ def run_migrations_online(): target_metadata=get_metadata(), process_revision_directives=process_revision_directives, include_object=include_object, + include_name=include_name, + include_schemas=True, **current_app.extensions["migrate"].configure_args )