Skip to content

MPT-17299: add status column to the list command#30

Merged
svazquezco merged 2 commits intomainfrom
MPT-17299-add-migration-status
Feb 3, 2026
Merged

MPT-17299: add status column to the list command#30
svazquezco merged 2 commits intomainfrom
MPT-17299-add-migration-status

Conversation

@svazquezco
Copy link
Collaborator

@svazquezco svazquezco commented Feb 3, 2026

Add status column to the list command

image

Closes MPT-17299

  • Add status column to the migrate list output (statuses: Running, Failed, Fake Apply, Applied, Not Applied)
  • Add MigrationStatusEnum with from_state(...) to derive status from started_at/applied_at timestamps
  • Introduce MigrationListItem dataclass to model list rows (migration_id, order_id, migration_type, started_at, applied_at, status)
  • Refactor rendering to MigrationRender class using Rich and Console(width=CONSOLE_WIDTH)
  • Update list use case to return list[MigrationListItem] sorted by order_id
  • Add CONSOLE_WIDTH constant (200) for consistent console width
  • Update run_migrations to track and persist status transitions (RUNNING, APPLIED, FAILED) and skip already-applied migrations
  • Update CLI tests and documentation to include and explain the new status column

@svazquezco svazquezco requested a review from a team as a code owner February 3, 2026 11:17
@svazquezco svazquezco requested review from alephsur and jentyk February 3, 2026 11:17
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Adds a migration status enum and list-item dataclass, changes listing use-case to return typed items, replaces table renderer with a Rich-aware MigrationRender class, updates run logic to persist status transitions, adds CONSOLE_WIDTH, and updates docs/tests to show a new status column.

Changes

Cohort / File(s) Summary
Documentation
docs/PROJECT_DESCRIPTION.md
Inserted explanation of how migration status is derived from persisted timestamps and added mapping (RUNNING, FAILED, FAKE_APPLY, APPLIED, NOT_APPLIED) in two places.
Constants
mpt_tool/constants.py
Added CONSOLE_WIDTH: int = 200.
Enums
mpt_tool/enums.py
Added MigrationStatusEnum (RUNNING, FAILED, FAKE_APPLY, APPLIED, NOT_APPLIED) and from_state(...) to derive status from a Migration instance or None.
Data Models
mpt_tool/models.py
Added frozen dataclass MigrationListItem with fields (migration_id, order_id, migration_type, started_at, applied_at, status) and from_sources(...) constructor using MigrationStatusEnum.from_state.
Rendering
mpt_tool/renders.py
Replaced functional table builder with MigrationRender class that accepts migration_items: list[MigrationListItem] and implements __rich_console__ to produce a Rich Table including the new status column and formatted values.
Commands
mpt_tool/commands/list.py
Renamed local variable state_datamigrations, changed emptiness check to if not migrations, instantiate Console(width=CONSOLE_WIDTH), and call MigrationRender(migration_items=migrations) for rendering.
Use Case — Listing
mpt_tool/use_cases/list_migrations.py
execute() now returns list[MigrationListItem]; constructs items via MigrationListItem.from_sources(...), logs missing states, and returns items sorted by order_id.
Use Case — Running
mpt_tool/use_cases/run_migrations.py
Introduced status-driven helpers: _get_migration_instance_by_type, _save_state and status transitions using MigrationStatusEnum (RUNNING/ APPLIED/ FAILED). Skips already-applied migrations and consistently wraps errors.
Tests
tests/cli/test_cli_airtable_storage.py, tests/cli/test_cli_local_storage.py
Updated CLI table expectations to include a status column (e.g., Applied / NotApplied), adjusted timestamps/freeze_time and migration_id expectations to match new rendering and data model.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key in the required format MPT-XXXX, properly formatted and separated from the description with a colon.
Test Coverage Required ✅ Passed PR modifies 7 code files and includes test changes in 2 test files, satisfying the requirement.
Single Commit Required ✅ Passed The PR contains exactly one commit (110289f feat: add status column to the list command), which meets the requirement for a clean and focused git history.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • MPT-17299: Cannot read properties of undefined (reading 'map')

Comment @coderabbitai help to get the list of available commands and usage tips.

@svazquezco svazquezco force-pushed the MPT-17299-add-migration-status branch 2 times, most recently from 2018010 to 4ff912f Compare February 3, 2026 11:45
@svazquezco svazquezco force-pushed the MPT-17299-add-migration-status branch from 4ff912f to d0ece9e Compare February 3, 2026 11:45
@svazquezco svazquezco force-pushed the MPT-17299-add-migration-status branch from d0ece9e to 110289f Compare February 3, 2026 11:47
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@mpt_tool/renders.py`:
- Line 15: Remove the unnecessary "# noqa: PLW3201" directive from the
__rich_console__ method signature (def __rich_console__(self, console: Console,
options: ConsoleOptions) -> RenderResult) since PLW3201 is not enforced by our
linters; simply delete the trailing noqa comment so the method signature is
clean.

In `@mpt_tool/use_cases/run_migrations.py`:
- Around line 52-55: Currently the code calls self._save_state(state,
status=MigrationStatusEnum.RUNNING) before executing migration_instance.run(),
which can leave migrations stuck as STARTED after a crash; remove or move that
pre-run persistence so you do not persist RUNNING before execution — instead
call self._save_state(...) with MigrationStatusEnum.RUNNING only after run() has
successfully started/finished as appropriate, or persist only immutable pre-run
metadata and persist RUNNING in the success path; update the block around
logger.info, self._save_state, and migration_instance.run() to ensure RUNNING is
not written prior to calling migration_instance.run().

@svazquezco svazquezco merged commit a52c621 into main Feb 3, 2026
4 checks passed
@svazquezco svazquezco deleted the MPT-17299-add-migration-status branch February 3, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants