Skip to content

[4.x] Add --skip-tenants option to HasTenantOptions#1436

Merged
stancl merged 7 commits into
archtechx:masterfrom
jimish-gamit:feat/skip-tenants
Jun 7, 2026
Merged

[4.x] Add --skip-tenants option to HasTenantOptions#1436
stancl merged 7 commits into
archtechx:masterfrom
jimish-gamit:feat/skip-tenants

Conversation

@jimish-gamit

@jimish-gamit jimish-gamit commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a --skip-tenants option to all tenant artisan commands (tenants:run, tenants:migrate, tenants:rollback, tenants:seed, tenants:up, tenants:down).

The option is the complement of the existing --tenants option instead of specifying which tenants to include, you specify which to exclude.

Changes

  • src/Concerns/HasTenantOptions.php Added --skip-tenants=* option to getOptions() and a whereNotIn clause in getTenantsQuery() to exclude the specified tenants from the query. Since all tenant commands share this trait, the option is available across all of them.
  • src/Commands/Run.php Added --skip-tenants=* to the command signature so it appears in tenants:run --help.

Usage

# Works on all tenant commands
php artisan tenants:migrate --skip-tenants=tenant3

Summary by CodeRabbit

  • New Features

    • Added a --skip-tenants option to tenant console commands to exclude specific tenants from execution.
    • --skip-tenants can be combined with --tenants for precise inclusion/exclusion control.
  • Tests

    • Added tests verifying skipped tenants are not acted on and combined --tenants + --skip-tenants behavior is correct.

@codecov

codecov Bot commented Mar 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.00%. Comparing base (dfb0e1a) to head (f524006).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1436      +/-   ##
============================================
+ Coverage     85.98%   86.00%   +0.01%     
  Complexity     1175     1175              
============================================
  Files           185      185              
  Lines          3425     3429       +4     
============================================
+ Hits           2945     2949       +4     
  Misses          480      480              

☔ 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.

@jimish-gamit jimish-gamit marked this pull request as draft March 2, 2026 07:14
@jimish-gamit jimish-gamit marked this pull request as ready for review March 2, 2026 08:06
@gjimish

gjimish commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Hi @stancl

Just checking in on this PR. Let me know if there’s any feedback or changes needed from my side, happy to update it.

Thanks for your time!

@stancl stancl changed the title [Feature] --skip-tenants option to tenant commands [4.x] Add --skip-tenants option to HasTenantOptions Mar 9, 2026
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 15479d12-26ea-4852-8d35-0575c7bbb7c2

📥 Commits

Reviewing files that changed from the base of the PR and between 00f4e9f and f524006.

📒 Files selected for processing (1)
  • src/Concerns/HasTenantOptions.php

📝 Walkthrough

Walkthrough

Adds a --skip-tenants option to tenant-aware Artisan commands. The trait registers the option and excludes specified tenants via a whereNotIn tenant query; the tenants:run signature is updated and tests cover skip behavior and interaction with --tenants.

Changes

Tenant Skipping Functionality

Layer / File(s) Summary
Option Registration & Query Filtering
src/Concerns/HasTenantOptions.php
Trait registers skip-tenants via getOptions() and applies a conditional whereNotIn() in getTenantsQuery() to exclude specified tenant keys.
Command Signature
src/Commands/Run.php
tenants:run command signature updated to add the {--skip-tenants=*} option.
Tests
tests/CommandsTest.php
Three Pest tests added: migrate commands skip specified tenants, run command omits skipped tenants from output, and combined --tenants + --skip-tenants excludes skipped tenants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through options, small and neat,
Skipped a few tenants with nimble feet.
Commands now whisper which ones to keep,
While I munch carrots and watch logs sleep.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a --skip-tenants option to the HasTenantOptions trait, which is the core objective across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/CommandsTest.php`:
- Around line 519-540: The pest()->artisan(...) invocation in the test closure
(the migrate commands test that creates tenant1/2/3) lacks an exit-code
assertion; modify the call to chain an assertion (for example
->assertExitCode(0) or ->assertSuccessful()) onto the pest()->artisan(...)
expression so the test fails if the artisan command crashes before the
subsequent tenancy/schema expectations run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4729a91a-4d8b-45e5-8b47-efbd6a742e1e

📥 Commits

Reviewing files that changed from the base of the PR and between 8f3ea62 and 00f4e9f.

📒 Files selected for processing (3)
  • src/Commands/Run.php
  • src/Concerns/HasTenantOptions.php
  • tests/CommandsTest.php

Comment thread tests/CommandsTest.php
@stancl stancl self-assigned this May 5, 2026
@stancl stancl merged commit 652bc98 into archtechx:master Jun 7, 2026
8 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.

4 participants