Skip to content

Use newMigrationPath and newMigrationNamespace if sourceNamespaces and sourcePaths are not specified#333

Merged
Tigrov merged 13 commits into
masterfrom
use-newmigrationpath
May 6, 2026
Merged

Use newMigrationPath and newMigrationNamespace if sourceNamespaces and sourcePaths are not specified#333
Tigrov merged 13 commits into
masterfrom
use-newmigrationpath

Conversation

@Tigrov
Copy link
Copy Markdown
Member

@Tigrov Tigrov commented Mar 19, 2026

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 12.66%. Comparing base (8e49f6f) to head (858c074).

Files with missing lines Patch % Lines
src/Service/MigrationService.php 0.00% 25 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #333      +/-   ##
============================================
- Coverage     12.85%   12.66%   -0.19%     
- Complexity      294      300       +6     
============================================
  Files            20       20              
  Lines           949      963      +14     
============================================
  Hits            122      122              
- Misses          827      841      +14     

☔ View full report in Codecov by Sentry.
📢 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 Copilot March 19, 2026 20:01
@samdark
Copy link
Copy Markdown
Member

samdark commented Mar 19, 2026

Good idea, @Tigrov. Need a CHANGELOG for it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates migration discovery for migrate:up so that when sourceNamespaces/sourcePaths are not provided, the service falls back to newMigrationNamespace/newMigrationPath, aligning runtime behavior with common configuration patterns and improving developer ergonomics.

Changes:

  • Extend MigrationService::before('migrate:up') validation to accept newMigrationNamespace/newMigrationPath as valid migration sources.
  • Refactor migration source resolution into MigrationService::findSourcePaths() and use it for scanning and loading migrations.
  • Add/update tests and documentation to cover and describe the fallback behavior (plus a small docs typo fix).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Common/Command/AbstractUpdateCommandTest.php Adds coverage for running updates when sourcePaths/sourceNamespaces are empty but newMigrationPath/newMigrationNamespace are set.
src/Service/MigrationService.php Introduces findSourcePaths() and uses it to discover migrations, including fallback to newMigration* settings.
docs/guide/pt-BR/usage-with-yii-console.md Documents the new fallback behavior (pt-BR).
docs/guide/pt-BR/usage-standalone.md Updates standalone example to setNewMigrationPath() and fixes helper key typo (pt-BR).
docs/guide/en/usage-with-yii-console.md Documents the new fallback behavior (EN).
docs/guide/en/usage-standalone.md Updates standalone example to setNewMigrationPath() and fixes helper key typo (EN).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Common/Command/AbstractUpdateCommandTest.php Outdated
Comment thread src/Service/MigrationService.php Outdated
Comment thread src/Service/MigrationService.php
Copy link
Copy Markdown
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

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

This solution brings a DX problem.

Step 1. Developer uses only newMigration* options. Everything is working.

Step 2. Developer adds source* option (e.g., he adds new module). Current migrations breaks, because they are not found.

Maybe we must always use newMigration* options as source?

@Tigrov
Copy link
Copy Markdown
Member Author

Tigrov commented May 4, 2026

Maybe we must always use newMigration* options as source?

Looks reasonable, updated.

Also I added tests with different ways how to specify migration paths and 3 bugs were discovered:

  1. If a path is specified, the namespace is not substituted;
  2. If one namespace matches multiple paths, only one path will be found;
  3. If one path corresponds to several namespaces, the same migrations along this path with different namespaces will be found.

Comment thread CHANGELOG.md Outdated
Comment thread src/Service/MigrationService.php Outdated
Comment thread src/Service/MigrationService.php Outdated
Comment thread src/Service/MigrationService.php Outdated
Comment thread src/Service/MigrationService.php Outdated
@vjik vjik mentioned this pull request May 5, 2026
3 tasks
@Tigrov Tigrov requested a review from vjik May 5, 2026 13:20
@Tigrov Tigrov merged commit e703759 into master May 6, 2026
54 of 56 checks passed
@Tigrov Tigrov deleted the use-newmigrationpath branch May 6, 2026 01:49
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.

4 participants