Communication Templates — Deployment
Production deploy (migrate-only)
bash
php artisan migrate --force
php artisan optimizeThis ships:
- Schema for
communication_templates - Catalog row + workspace entitlements for
communication-templates(data migration) - Additive permission grants for default roles (data migration)
Do not run db:seed, CatalogSeeder, or any permission seeder in production for this module.
What the data migrations do (and do not do)
register_communication_templates_module
Uses App\Support\Catalog\DefaultModuleRegistrar:
- Inserts the CRM category if missing
- Inserts the
communication-templatesmodule only if the slug is missing - Never overwrites commercial flags, prices, or renamed catalog fields
- Installs an included subscription only for workspaces that have never had a subscription row for that module (including soft-deleted rows)
- Does not reactivate cancelled, suspended, or soft-deleted subscriptions
- Clears entitlement cache only for workspaces that received a new install
add_communication_template_permissions
Uses App\Support\Permissions\TenantPermissionSynchronizer:
- Creates missing
communication-templates.*permission vocabulary rows - Grants only those permissions to default roles that should have them
- Never runs
syncPermissions()on existing roles - Never removes customized role permissions
- Idempotent: re-running creates zero duplicates
New workspaces
TenantProvisioningService (before owner creation):
ModuleSubscriptionService::installDefaultModules()— every publishedis_default_includedmoduleTenantAuthorizationProvisioningService::provisionDefaults()— workspace roles + default permission maps
Login / dashboard / role listing never provision or repair RBAC.
Future modules
Copy this pattern for each new default-included module:
- Schema migration(s) for domain tables
- Data migration using
DefaultModuleRegistrar - Data migration using
TenantPermissionSynchronizer::grantMissingDefaultRolePermissions([...]) - Keep
CatalogSeederin sync for fresh local/CI databases only
Verification
bash
php artisan test --compact tests/Feature/ProductionModuleDeploymentTest.php
php artisan test --compact tests/Feature/Tenant/CommunicationTemplatesFrontend (optional):
bash
cd SaaS-Frontend
npm run test:e2e:communication-templatesSmoke after deploy:
- Existing workspace sees Templates in nav (module installed + permissions granted)
- Lead detail shows WhatsApp when phone is present
- Marketplace/commercial flags for other modules remain unchanged
- A customized staff role that had permissions removed does not regain revoked permissions (only the listed new grants are added)