CLI
After enabling a module, the routes may exist while existing roles still lack its features. Synchronize the default feature assignments, then check access with the intended role.
yarn mercato auth sync-role-acls merges each enabled module's setup.defaultRoleFeatures into the RoleAcl rows of the target tenant(s). It is the recovery command when a tenant's role ACLs have drifted – for example, after a demo user detached features from admin, or after a module upgrade introduced new features that were never propagated to pre-existing tenants.
# Sync a single tenant (recommended)
yarn mercato auth sync-role-acls --tenant <tenantId>
# Sync every tenant in the connected database
yarn mercato auth sync-role-acls
# Skip the superadmin role (defensive — superadmin grants isSuperAdmin)
yarn mercato auth sync-role-acls --tenant <tenantId> --no-superadmin
| Flag | Default | Meaning |
|---|---|---|
--tenant <id> | none – iterates every tenant | Restrict the sync to one tenant. Accepts --tenantId and --tenant_id as aliases. |
--no-superadmin | off (superadmin is synced) | Skip writing the superadmin role ACL. Use when you do not want to touch isSuperAdmin on the target tenant. |
defaultRoleFeatures from every enabled module (via getCliModules()).superadmin, admin, employee, and any custom roles declared by modules.ensureRoleAclFor, which:
RoleAcl row if missing.✅ Synced role ACLs for tenant <id> per tenant.admin role lost features and users can no longer reach guarded pages.defaultRoleFeatures that existing tenants never received (setupTenantAndPrimaryUser only runs during initial tenant creation).defaultRoleFeatures entries for non-built-in roles are synced for every tenant that already has those roles.mercato auth seed-roles. This command assumes the roles already exist – it does not create them.seed:defaults. It does not seed dictionaries, currencies, or example data. It only syncs role feature ACLs.❌ No CLI modules registered. Run \yarn generate` first.` – regenerate the module aggregation files.❌ Invalid --tenant value: … – the value was empty or whitespace. Pass a UUID from yarn mercato auth list-tenants.No tenants found; nothing to sync. – the no-flag form found zero tenants. Ensure DATABASE_URL points to the expected environment.src/modules.ts and that its setup.ts lists the feature under defaultRoleFeatures.auth seed-roles – ensures the employee/admin/superadmin roles exist.auth setup – full initial tenant bootstrap (calls this logic internally).