Skip to content

Commit b176068

Browse files
committed
Update clean_up to drop change_log table
1 parent 6e420aa commit b176068

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/psycopack/_repack.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,13 @@ def clean_up(self) -> None:
632632
self.command.drop_table_if_exists(table=self.backfill_log)
633633
self.registry.delete_row_for(table=self.table)
634634

635+
if self.sync_strategy == _sync_strategy.SyncStrategy.CHANGE_LOG:
636+
# The change log trigger and function have already been
637+
# dropped during the schema sync stage. The table is the
638+
# only artefact remaining.
639+
assert self.change_log is not None
640+
self.command.drop_table_if_exists(table=self.change_log)
641+
635642
def reset(self) -> None:
636643
current_stage = self.tracker.get_current_stage()
637644
if current_stage == _tracker.Stage.PRE_VALIDATION:

tests/test_repack.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,16 @@ def test_repack_with_changes_log_strategy(
25432543

25442544
table_before = _collect_table_info(table="to_repack", connection=connection)
25452545
repack.swap()
2546+
2547+
# Before the clean-up, the change_log table is still there.
2548+
assert repack.change_log is not None
2549+
repack.introspector.get_table_oid(table=repack.change_log)
2550+
25462551
repack.clean_up()
2552+
2553+
# After the clean-up, the change_log table has been deleted.
2554+
repack.introspector.get_table_oid(table=repack.change_log)
2555+
25472556
table_after = _collect_table_info(table="to_repack", connection=connection)
25482557
_assert_repack(
25492558
table_before=table_before,

0 commit comments

Comments
 (0)