fix: Allow dry-run even when migration is in progress

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 <noreply@anthropic.com>
This commit is contained in:
2025-12-27 09:43:45 +01:00
parent 58624c0866
commit f3768d8174

View File

@@ -78,14 +78,15 @@ class FullMigrator:
logger.warning( logger.warning(
f"Found previous migration state: {pg_row_count} rows already in {pg_table}" 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( raise ValueError(
f"Migration already in progress for {pg_table}. " f"Migration already in progress for {pg_table}. "
f"Use --resume to continue from last checkpoint, or delete data to restart." 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 resume:
if last_completed_partition: logger.info(f"Resuming migration - found {pg_row_count} existing rows")
logger.info(f"Last completed partition: {last_completed_partition}") if last_completed_partition:
logger.info(f"Last completed partition: {last_completed_partition}")
# Progress bar tracks MySQL rows processed (before consolidation) # Progress bar tracks MySQL rows processed (before consolidation)
# Consolidation reduces count but not the rows we need to fetch # Consolidation reduces count but not the rows we need to fetch
rows_to_migrate = total_rows rows_to_migrate = total_rows
@@ -95,7 +96,10 @@ class FullMigrator:
rows_to_migrate = total_rows rows_to_migrate = total_rows
if dry_run: 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 return rows_to_migrate
migrated = previous_migrated_count migrated = previous_migrated_count