Skip to content

Add migrations:skip command and --all-connections support#327

Merged
usernane merged 2 commits into
mainfrom
dev
May 13, 2026
Merged

Add migrations:skip command and --all-connections support#327
usernane merged 2 commits into
mainfrom
dev

Conversation

@usernane
Copy link
Copy Markdown
Member

@usernane usernane commented May 13, 2026

Summary

Two migration CLI features:

  1. migrations:skip command for baselining existing databases
  2. --all-connections flag on migrations:run for multi-database architectures

Motivation

  • Baselining: When adopting the migration system on an existing database, developers need to mark migrations as "applied" without executing them.
  • Multi-connection: In systems with multiple databases, migrations can target specific connections. The CLI needs to support running against all connections and validating configuration.

Changes

migrations:skip (Closes #320)

  • New SkipMigrationsCommand with three modes: --name, --all, --up-to
  • Registered in App.php
  • 11 tests

--all-connections (Closes #326)

  • Added --all-connections flag to migrations:run
  • Added validateTargetConnections() — warns about unknown target names and default connection names
  • Fixed bug in JsonDriver::getDBConnection() where connection name was lost
  • 10 tests

How to Test / Verify

php vendor/bin/phpunit -c tests/phpunit10.xml --testsuite "CLI Tests" --filter "SkipMigrations|ConnectionTargeted"

21 tests pass. Full CLI suite: 192 tests, 0 failures.

Breaking Changes and Migration Steps

None

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #320
Closes #326
Depends on: WebFiori/database#149

Add a CLI command to mark migrations as applied without executing them.
Supports three modes:
- --name: skip a single migration by class name
- --all: skip all pending migrations (full baseline)
- --up-to: skip all up to and including a named migration

Closes #320
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 96.59367% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.05%. Comparing base (be6d69d) to head (5a4daea).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...Framework/Cli/Commands/RunMigrationsCommandNew.php 83.82% 11 Missing ⚠️
WebFiori/Framework/Config/JsonDriver.php 99.12% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #327      +/-   ##
============================================
+ Coverage     74.99%   75.05%   +0.06%     
- Complexity     3015     3034      +19     
============================================
  Files            97       97              
  Lines          9589     9650      +61     
============================================
+ Hits           7191     7243      +52     
- Misses         2398     2407       +9     
Flag Coverage Δ
php-8.1 76.36% <96.21%> (+0.06%) ⬆️
php-8.2 76.32% <96.21%> (+0.06%) ⬆️
php-8.3 75.12% <96.59%> (+0.06%) ⬆️
php-8.4 75.12% <96.59%> (+0.06%) ⬆️
php-8.5 75.03% <96.59%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@usernane usernane changed the title Add migrations:skip command for baselining existing databases Add migrations:skip command and --all-connections support May 13, 2026
…igrations

Add support for running migrations against all registered connections
in a single command invocation. Also validates that migration target
connection names exist in the registry and warns about default names.

Changes:
- Add --all-connections flag to migrations:run
- Add validateTargetConnections() for typo/misconfiguration detection
- Fix JsonDriver::getDBConnection() using wrong variable for connection-name

Closes #326
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
31.1% Duplication on New Code (required ≤ 6%)

See analysis details on SonarQube Cloud

@usernane usernane merged commit 9f2efb0 into main May 13, 2026
25 of 26 checks passed
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.

feat(cli): Add CLI support for connection-targeted migrations feat(cli): Add migrations:skip command for baselining existing databases

1 participant