diff --git a/src/brad/admin/bootstrap_schema.py b/src/brad/admin/bootstrap_schema.py index 95efddab..58c3f6b4 100644 --- a/src/brad/admin/bootstrap_schema.py +++ b/src/brad/admin/bootstrap_schema.py @@ -42,6 +42,12 @@ def register_admin_action(subparser) -> None: help="Set this flag to avoid persisting the blueprint. " "Only meant to be used if you know what you are doing!", ) + parser.add_argument( + "--bare-aurora-tables", + action="store_true", + help="If set, do not create the shadow tables and triggers " + "for Aurora. Only meant to be used if you know what you are doing!", + ) parser.set_defaults(admin_action=bootstrap_schema) @@ -100,7 +106,9 @@ def bootstrap_schema(args): table.name, location, ) - queries, db_type = sql_gen.generate_create_table_sql(table, location) + queries, db_type = sql_gen.generate_create_table_sql( + table, location, args.bare_aurora_tables + ) conn = cxns.get_connection(db_type) cursor = conn.cursor_sync() for q in queries: @@ -108,7 +116,7 @@ def bootstrap_schema(args): cursor.execute_sync(q) # 7. Create and set up the extraction progress table. - if Engine.Aurora in engines_filter: + if Engine.Aurora in engines_filter and not args.bare_aurora_tables: queries, db_type = sql_gen.generate_extraction_progress_set_up_table_sql() conn = cxns.get_connection(db_type) cursor = conn.cursor_sync() diff --git a/src/brad/blueprint/sql_gen/table.py b/src/brad/blueprint/sql_gen/table.py index 59b2d082..2b3b5d94 100644 --- a/src/brad/blueprint/sql_gen/table.py +++ b/src/brad/blueprint/sql_gen/table.py @@ -36,7 +36,7 @@ def __init__(self, config: ConfigFile, blueprint: Blueprint): self._blueprint = blueprint def generate_create_table_sql( - self, table: Table, location: Engine + self, table: Table, location: Engine, bare_aurora_tables: bool = False ) -> Tuple[List[str], Engine]: """ Returns SQL queries that should be used to create `table` on `location`, @@ -44,7 +44,10 @@ def generate_create_table_sql( """ if location == Engine.Aurora: - if table.name in self._blueprint.base_table_names(): + if ( + not bare_aurora_tables + and table.name in self._blueprint.base_table_names() + ): # This table needs to support incremental extraction. We need to # create several additional structures to support this extraction. columns_with_types = comma_separated_column_names_and_types(