CLI
Initialize a new workspace after its infrastructure is available. The flags distinguish the identities needed for access from example records used for development.
The yarn initialize script wraps the Open Mercato CLI mercato init command and delivers a ready-to-run workspace. It installs dependencies, prepares generated module artifacts, applies database migrations, seeds baseline RBAC data, and populates demo CRM content (companies, people, deals, activities, todos) unless you disable it with --no-examples. Enable --stresstest to tack on a synthetic, high-volume dataset that includes additional companies, pipeline deals, activities, and notes – all wired with realistic custom field values and a live progress bar.
yarn initialize [--org=<name>] [--email=<address>] [--password=<value>] [--roles=<csv>] [--skip-password-policy] [--no-examples] [--no-demo-users] [--stresstest] [--lite] [-n <count>] [--count=<count>] [--reinstall|-r] [--skip-if-initialized]
Ensure DATABASE_URL points to the Postgres instance you want to initialize before running the command.
| Option | Description | Default |
|---|---|---|
--org, --orgName | Name of the organization that will be created. | Acme Corp |
--email | Superadmin login email. Companion admin@… and employee@… accounts are also provisioned. | [email protected] |
--password | Password applied to all seeded accounts. | a legacy development password outside production; required in production |
--roles | Comma-separated list of roles ensured before user creation. | superadmin,admin,employee |
--skip-password-policy | Skip password policy validation outside production (useful for demo defaults like a legacy development password). Ignored in production. | on outside production |
--no-examples | Skip demo CRM seeders (companies, people, deals, activities, todos). Alias: --no-exampls. | off |
--no-demo-users | Skip seeding the derived admin@…/employee@… demo accounts – only the --email superadmin account is created. | off |
--stresstest | Generate a high-volume synthetic CRM dataset (contacts, companies, deals, activities, notes) in addition to the curated examples. | off |
--lite | When paired with --stresstest, skips deals, activities, notes, and custom fields for faster high-volume contact generation. | off |
-n, --count, --stress-count, --stresstest-count | Number of synthetic contacts to create when --stresstest is enabled. | 6000 |
--reinstall, -r | Drops every table in the target database before bootstrapping. Requires a valid DATABASE_URL. | off |
--skip-if-initialized | When the target database already has users, keep the data, print which database (host:port/name) was kept and exit successfully instead of aborting. A database without users is initialized as usual. yarn setup passes it on every run except --reinstall, so re-running setup never touches existing data. Ignored together with --reinstall. | off |
When you omit CLI flags, the init flow will read environment defaults for the seeded accounts:
| Variable | Description | Default |
|---|---|---|
OM_INIT_SUPERADMIN_EMAIL | Superadmin login email used when --email is not provided. | [email protected] |
OM_INIT_SUPERADMIN_PASSWORD | Superadmin password used when --password is not provided. | a legacy development password outside production; required in production |
OM_INIT_ADMIN_EMAIL | Derived admin account email override. | admin@<superadmin-domain> |
OM_INIT_EMPLOYEE_EMAIL | Derived employee account email override. | employee@<superadmin-domain> |
OM_INIT_ADMIN_PASSWORD | Admin account password override. When unset, a random 16-char base64url password is generated and surfaced in the init summary. | (randomly generated) |
OM_INIT_EMPLOYEE_PASSWORD | Employee account password override. When unset, a random 16-char base64url password is generated and surfaced in the init summary. | (randomly generated) |
OM_INIT_GENERATE_RANDOM_PASSWORD | Deprecated, no-op. Random derived passwords are now the unconditional default when overrides are unset; setting the flag prints a one-time deprecation warning and is otherwise ignored. | (unused) |
yarn initialize passes --include-demo-users to mercato auth setup so the derived admin@… / employee@… demo accounts are seeded as part of the dev/demo bootstrap. Standalone callers of mercato auth setup must opt in themselves; without that flag, no demo accounts are seeded. Pass --no-demo-users to mercato init/yarn initialize to skip them too – for example on a production bootstrap where only the --email superadmin account should exist.
When NODE_ENV=production (case-insensitive, surrounding whitespace ignored), set a unique OM_INIT_SUPERADMIN_PASSWORD or pass --password before initialization. Missing, blank, and built-in placeholder passwords are rejected before initialization writes, including table drops during --reinstall. With --skip-if-initialized, the database preflight runs first so an existing initialized database needs no bootstrap credential; an empty database may be created during that preflight. Operator-provided passwords must satisfy the configured OM_PASSWORD_* policy; --skip-password-policy and --allow-weak-password cannot bypass it in production. Non-production defaults are unchanged.
The starter and generated-app full-app Compose files default to production. Their a legacy development password fallback supports non-production overrides only and is rejected during production initialization. Configure the secret in the deployment environment before the first boot. This does not rotate credentials in an existing database; rotate any previously deployed default passwords separately.
yarn install.configs restore-defaults).auth setup to create the tenant, organization, and user accounts specified.feature_toggles seed-defaults).auth seed-roles).customers seed-dictionaries).catalog seed-units).TENANT_DATA_ENCRYPTION is enabled).--no-examples is present, seeds demo CRM data (customers seed-examples), catalog examples, sales examples, and example Todos (example seed-todos).--stresstest is present, seeds synthetic contacts, companies, deals, activities, and notes with custom fields (and a progress bar) via customers seed-stresstest. Add --lite to focus on raw contacts without the heavier extras.dashboards seed-defaults).Without --reinstall, the command first checks the users table. When it already has rows, it aborts with a hint to run yarn mercato init --reinstall, unless --skip-if-initialized is passed: then it prints Database already initialized (N user(s) in host:port/name) and exits with code 0 without running any of the steps above. Check that name if you did not expect an initialized database: DATABASE_URL may point at another project's database.
On success, the command prints a boxed summary with created accounts and their passwords.
Info · Performance Improvement
The init command now calls CLI handlers directly instead of spawning separate processes for each step. This significantly reduces initialization time by eliminating ~25+ process spawns and maintaining shared state (DI container, entity IDs, etc.) across all operations.
When --reinstall is present the command:
dotenv/config.public schema using CASCADE.--no-examples).Use this mode for destructive resets in development. Never run it against production databases.
DATABASE_URL – the command aborts before performing database work. Export the variable or place it in .env.yarn install manually to inspect the error, then re-run yarn initialize.Previous: mercato feature_toggles toggle-update · Next: mercato module add