Skip to content

Fix #363: Add migrate:mark to move migration history to a version without executing migrations - #364

Merged
samdark merged 8 commits into
masterfrom
issue-363-migrate-mark
Oct 7, 2026
Merged

samdark merged 8 commits into
masterfrom
issue-363-migrate-mark

Conversation

@samdark

@samdark samdark commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Adds migrate:mark <version> for databases where migration changes already exist. A pending target records migrations through that version; an applied target removes newer history entries. Neither operation runs migration methods.

Supports full migration class names, migration timestamps, and m000000_000000_base to reset history. Includes confirmation, --force-yes, and explicit --db selection when multiple databases are configured. Adds command registration, documentation, and regression tests. Includes a prominent guide warning and a shorter command-description warning about the risks of changing migration history.

Fixes #363.

Q A
Is bugfix? ❌
New feature? ✔️
Breaks BC? ❌

Copilot AI balanced review requested due to automatic review settings October 3, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Target resolution can reject valid names, select the wrong history range, or fail unnecessarily when migration sources are missing.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Adds migrate:mark to manage migration history without executing migrations, supporting adoption of existing databases described in #363.

Changes:

  • Adds version selection, history reset, confirmation, and explicit database selection.
  • Registers the command across supported integrations and documents its behavior.
  • Adds shared driver tests and regression fixtures.
File Description
tests/​Support/​MarkMigrations/​M260101000003Third.php Guards against migration execution.
tests/​Support/​MarkMigrations/​M260101000002Second.php Provides a target fixture.
tests/​Support/​MarkMigrations/​M260101000001First.php Provides an earlier migration fixture.
tests/​Migration/​ConfigTest.php Checks command resolution.
tests/​Migration/​BinTest.php Checks standalone command availability.
tests/​Driver/​Sqlite/​MarkCommandTest.php Runs shared SQLite tests.
tests/​Driver/​Sqlite/​DatabaseCommandsTest.php Tests database isolation and history reset.
tests/​Driver/​Pgsql/​MarkCommandTest.php Runs shared PostgreSQL tests.
tests/​Driver/​Oracle/​MarkCommandTest.php Runs shared Oracle tests.
tests/​Driver/​Mysql/​MarkCommandTest.php Runs shared MySQL tests.
tests/​Driver/​Mssql/​MarkCommandTest.php Runs shared SQL Server tests.
tests/​Common/​Command/​AbstractMarkCommandTest.php Tests marking behavior and confirmation.
src/​Migrator.php Exposes history-only operations.
src/​Command/​MarkCommand.php Implements the new command.
src/​Command/​DatabaseCommand.php Requires database selection when needed.
src/​Command/​CommandFactory.php Constructs the command.
README.md Lists the new command.
docs/​guide/​en/​usage-with-symfony.md Documents Symfony registration.
docs/​guide/​en/​README.md Links the history guide.
docs/​guide/​en/​multiple-databases.md Documents database-specific marking.
docs/​guide/​en/​migration-history.md Explains marking behavior and risks.
config/​params.php Registers the console command.
config/​di-console.php Adds dependency-injection wiring.
CHANGELOG.md Records the feature.
bin/​yii-db-migration Registers standalone usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Command/MarkCommand.php Outdated
Comment thread src/Command/MarkCommand.php Outdated
Comment thread src/Command/MarkCommand.php
@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.38%. Comparing base (3c06394) to head (d1fd8f2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #364      +/-   ##
============================================
+ Coverage     97.21%   97.38%   +0.17%     
- Complexity      347      375      +28     
============================================
  Files            25       26       +1     
  Lines          1114     1187      +73     
============================================
+ Hits           1083     1156      +73     
  Misses           31       31              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samdark
samdark requested a review from a team October 5, 2026 12:05
Comment thread src/Migrator.php Outdated
Comment thread src/Migrator.php Outdated
Comment thread src/Migrator.php Outdated
Comment thread src/Migrator.php Outdated
@samdark
samdark requested a review from Tigrov October 6, 2026 18:35
Comment thread src/Command/MarkCommand.php
@samdark samdark changed the title Add migrate:mark command to manage migration history Fix #363: Add migrate:mark to move migration history to a version without executing migrations Oct 7, 2026
@samdark
samdark merged commit 9cc88b7 into master Oct 7, 2026
58 checks passed
@samdark
samdark deleted the issue-363-migrate-mark branch October 7, 2026 07:05
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.

It is not possible to mark migrations as completed.

3 participants