feat: Add --partition flag to migrate only specific partition

Allows testing/debugging by migrating only a single partition instead of
the entire table. Useful for:
- Testing consolidation on specific partitions
- Quick verification of fixes without full migration
- Targeted debugging

Usage:
    python3 main.py migrate full --table ELABDATADISP --partition d10
    python3 main.py migrate full --table RAWDATACOR --partition d11 --resume

Changes:
- Add partition parameter to FullMigrator.migrate()
- Filter partitions list to only specified partition if provided
- Validate partition exists in available partitions
- Add --partition CLI option to migrate full command
- Update message to show partition in progress

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-27 09:05:11 +01:00
parent 287a7ffb51
commit 58624c0866
2 changed files with 22 additions and 6 deletions

12
main.py
View File

@@ -74,7 +74,13 @@ def migrate():
is_flag=True,
help="Resume from last checkpoint if migration was interrupted"
)
def full(table, dry_run, resume):
@click.option(
"--partition",
type=str,
default=None,
help="Only migrate this partition (for testing/debugging)"
)
def full(table, dry_run, resume, partition):
"""Perform full migration of all data."""
setup_logger(__name__)
@@ -84,8 +90,8 @@ def full(table, dry_run, resume):
total_migrated = 0
for tbl in tables:
click.echo(f"\nMigrating {tbl}...")
migrated = run_full_migration(tbl, dry_run=dry_run, resume=resume)
click.echo(f"\nMigrating {tbl}" + (f" (partition {partition})" if partition else "") + "...")
migrated = run_full_migration(tbl, dry_run=dry_run, resume=resume, partition=partition)
total_migrated += migrated
click.echo(f"{tbl}: {migrated} rows migrated")