Skip to content

Guard help article tenancy schema#7

Merged
swilla merged 1 commit into
mainfrom
fix-tenancy-schema-guard
May 23, 2026
Merged

Guard help article tenancy schema#7
swilla merged 1 commit into
mainfrom
fix-tenancy-schema-guard

Conversation

@swilla
Copy link
Copy Markdown
Member

@swilla swilla commented May 23, 2026

Summary

  • add a shared tenancy helper that checks whether the configured tenant column actually exists before applying tenant-aware behavior
  • guard admin, frontend, guest, model scope, model auto-assignment, and factory tenant behavior against missing tenant columns
  • add regression coverage for the runtime guard when tenancy is enabled but the table does not have the tenant column

Why

Promote Synergy hit a paid-member Help Center 500 because tenancy scoping queried help_articles.team_id, but the existing table did not have that column. For greenfield installs, the existing create_help_articles_table migration already adds the tenant column when tenancy is enabled before migrations run. This PR keeps that greenfield migration path as-is and focuses on preventing config/schema drift from becoming a runtime 500.

Testing

  • php -d memory_limit=-1 vendor/bin/pest --compact tests/Unit/TenancyTest.php tests/Feature/FrontendHelpTest.php tests/Feature/AdminHelpArticleResourceTest.php
  • vendor/bin/pint --dirty --test

Notes

  • This intentionally does not add a follow-up repair migration. The package README already documents that tenancy must be enabled before running migrations; late tenancy enablement remains a manual database change.

@swilla swilla force-pushed the fix-tenancy-schema-guard branch from 23b258e to f604ce7 Compare May 23, 2026 17:25
@swilla swilla merged commit 724dee0 into main May 23, 2026
1 check 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.

1 participant