From f3768d8174f2a5b1992ec17a5884a54c25c56b8f Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 27 Dec 2025 09:43:45 +0100 Subject: [PATCH] fix: Allow dry-run even when migration is in progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: dry-run was blocked with 'Migration already in progress' error, even though dry-run should not require --resume (it doesn't modify data). Fix: Skip the 'already in progress' check if dry_run is True. This allows: - Testing partitions without interrupting active migration - Verifying what would be migrated without needing --resume - Checking consolidation logic on specific partitions Also improved dry-run message to show partition info if specified. 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 --- src/migrator/full_migration.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/migrator/full_migration.py b/src/migrator/full_migration.py index 433f350..07f2c04 100644 --- a/src/migrator/full_migration.py +++ b/src/migrator/full_migration.py @@ -78,14 +78,15 @@ class FullMigrator: logger.warning( f"Found previous migration state: {pg_row_count} rows already in {pg_table}" ) - if not resume: + if not resume and not dry_run: raise ValueError( f"Migration already in progress for {pg_table}. " f"Use --resume to continue from last checkpoint, or delete data to restart." ) - logger.info(f"Resuming migration - found {pg_row_count} existing rows") - if last_completed_partition: - logger.info(f"Last completed partition: {last_completed_partition}") + if resume: + logger.info(f"Resuming migration - found {pg_row_count} existing rows") + if last_completed_partition: + logger.info(f"Last completed partition: {last_completed_partition}") # Progress bar tracks MySQL rows processed (before consolidation) # Consolidation reduces count but not the rows we need to fetch rows_to_migrate = total_rows @@ -95,7 +96,10 @@ class FullMigrator: rows_to_migrate = total_rows if dry_run: - logger.info(f"[DRY RUN] Would migrate {rows_to_migrate} rows") + if partition: + logger.info(f"[DRY RUN] Would migrate partition {partition} (~{rows_to_migrate} total rows in table)") + else: + logger.info(f"[DRY RUN] Would migrate {rows_to_migrate} rows") return rows_to_migrate migrated = previous_migrated_count