From d3ada1ded2a0fec4a227e5443ec938418c00759f Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 23 Dec 2025 20:41:46 +0100 Subject: [PATCH] fix: Mark migration as completed when migration finishes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The _update_migration_state() method was using logic: status = "in_progress" if last_id is not None else "completed" This was incorrect because: 1. last_id is always set during periodic updates (to track resume point) 2. So status would always be "in_progress" even when migration finished 3. migration_completed_at would never be set Solution: Add is_final parameter to explicitly mark when migration is complete. During periodic updates, is_final=False (status="in_progress"). Only when called at the end, is_final=True (status="completed"). This ensures: - migration_state.status = "completed" when done - migration_state.migration_completed_at is set - Proper tracking for knowing if migration is finished 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 --- src/migrator/full_migration.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/migrator/full_migration.py b/src/migrator/full_migration.py index be9d731..cf965a3 100644 --- a/src/migrator/full_migration.py +++ b/src/migrator/full_migration.py @@ -179,7 +179,7 @@ class FullMigrator: logger.info(f"About to update migration_state with count={final_count}, last_id={final_last_id}") self._update_migration_state( - pg_conn, final_count, final_last_id, migration_start_time + pg_conn, final_count, final_last_id, migration_start_time, is_final=True ) logger.info(f"Migration state update complete") @@ -244,7 +244,8 @@ class FullMigrator: pg_conn: PostgreSQLConnector, rows_migrated: int, last_id: Optional[int] = None, - migration_start_time: Optional[str] = None + migration_start_time: Optional[str] = None, + is_final: bool = False ) -> None: """Update migration state in PostgreSQL and state file. @@ -253,10 +254,11 @@ class FullMigrator: rows_migrated: Total number of rows migrated so far last_id: Last ID that was migrated (for resume capability) migration_start_time: When the migration started (ISO format) + is_final: If True, mark migration as completed """ pg_table = self.config["postgres_table"] now = datetime.utcnow() - status = "in_progress" if last_id is not None else "completed" + status = "completed" if is_final else "in_progress" # Update PostgreSQL migration_state table try: