Platform Provisioning Commands
The CTMS platform is composed of three independent stacks — Supabase (auth + database), Frappe (healthcare backend), and CTMS Core (Zynexa, Sublink, analytics). Each stack requires its own provisioning step to create tables, seed master data, configure roles, and register demo users.
For the summary table of init commands, see the Platform Runbook → CTMS Init & Provisioning. This page covers detailed configuration, env variables, dry-run mode, and log analysis.
During a fresh deployment, zynctl.sh full-deploy runs these steps automatically. However, you may need to re-run them individually when:
- A provisioning step failed mid-way and you want to retry just that step
- You reset a database and need to re-seed it
- You added new demo users or master data to the seed containers
- You want to preview changes with dry-run mode before applying
All containers run under the Docker Compose init profile and are idempotent — existing records are skipped, so re-running is always safe.
Required (platform will not work without these): Supabase Seed, Frappe Init
Optional (demo/QA environments only): User Seed, Patient Seed, seed-demo-data.sh
Base Command
From the deployment directory:
cd /opt/ctms-deployment
DC="docker compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env.production"
Required — Platform Seed
These steps must run on every fresh deployment. The platform will not function correctly without them.
1. Supabase Seed
Seeds PostgreSQL tables, RLS policies, and database functions into Supabase.
Prerequisite: Supabase must be running.
$DC --profile init run --rm ctms-supabase-seed
| Variable | Default | Description |
|---|---|---|
DATABASE_URL | from .env.production | PostgreSQL connection string |
CTMS_SEED_DRY_RUN | false | Set to true to preview without applying |
2. Frappe Init (ctms-init)
Provisions Frappe with CTMS-specific configuration across 5 stages:
| Stage | Description | Records |
|---|---|---|
| 1 | Custom DocTypes (4 dependency phases) | 34 |
| 2 | Custom Fields on built-in DocTypes | 15 fields |
| 3 | RBAC — Roles, Resources, Actions, Permissions, Navigation | 539 |
| 4 | Master / Reference Data — Frappe base data, Item Groups, study-design lookups, drugs, sites, events | 142 |
| 5 | Default Healthcare Practitioner | 1 |
Prerequisite: Frappe must be running and FRAPPE_API_TOKEN must be set in .env.production.
$DC --profile init run --rm ctms-init
Run specific stages only
# Run only stages 4 and 5 (master data + practitioner)
CTMS_INIT_STAGES=4,5 $DC --profile init run --rm ctms-init
# Run only stage 5 (practitioner only — use if stages 1–4 already completed)
CTMS_INIT_STAGES=5 $DC --profile init run --rm ctms-init
# Dry run — preview what would be created
CTMS_INIT_DRY_RUN=true $DC --profile init run --rm ctms-init
| Variable | Default | Description |
|---|---|---|
FRAPPE_URL | from .env.production | Frappe backend URL |
FRAPPE_API_TOKEN | from .env.production | API token (key:secret) |
CTMS_INIT_STAGES | 1,2,3,4,5 | Comma-separated stages to run |
CTMS_INIT_DRY_RUN | false | Preview mode |
CTMS_INIT_LOG_LEVEL | INFO | Log verbosity (DEBUG, INFO, WARNING) |
PRACTITIONER_FIRST_NAME | Mary | Stage 5 practitioner first name |
PRACTITIONER_LAST_NAME | Williams | Stage 5 practitioner last name |
Optional — Demo Data
The following steps are not required for the platform to run. Use them in demo, QA, or onboarding environments to pre-populate users and patients.
3. Demo User Seed
Seeds 4 demo staff users into Zynexa via the signup API. Skip this for production environments where real users will be created through the UI.
Prerequisite: Zynexa must be running.
$DC --profile init run --rm ctms-user-seed
| User | Role |
|---|---|
| kiran.v@zynomi.com | Platform Administrator |
| michael.x@zynomi.com | Study Coordinator |
| roshini.s@zynomi.com | Study Designer |
| peter.p@zynomi.com | Principal Investigator |
All demo users use the default password configured during deployment.
Alternative: You can also use the zynctl command:
./zynctl.sh seed-users
4. Demo Patient Seed
Seeds 20 synthetic demo patients into Zynexa via the same signup API used by the "New Patient" UI form. Each patient gets a full user stack: Supabase Auth account → Frappe User → Frappe Patient.
Prerequisite: Zynexa must be running.
$DC --profile init run --rm ctms-patient-seed
Patient seed is useful for demo environments and QA testing where you need realistic patient data for studies, visits, and consent workflows. Skip it for production deployments or environments where patients will be enrolled organically.
| Field | Example Values |
|---|---|
| Names | Sarah Chen, James Rodriguez, Emily Thompson, … |
| Emails | *@subject.com |
| Password | Default demo password |
| Role | Patient |
| Gender | Male / Female |
| DOB | Range: 1955–2000 |
| Variable | Default | Description |
|---|---|---|
API_HOST | http://zynexa:3000 | Zynexa base URL (Docker internal) |
CSV_FILE | /app/data/synthetic/syn_patients.csv | Path to patient CSV inside container |
DRY_RUN | false | Set to true to preview payloads without creating patients |
Dry Run
DRY_RUN=true $DC --profile init run --rm ctms-patient-seed
5. seed-demo-data.sh (All-in-One)
A self-contained script that seeds users and/or patients directly via the Zynexa API. No Docker Compose needed — just point it at the running server.
Prerequisite: Zynexa must be running and reachable.
cd /opt/ctms-deployment
# Seed staff users only
API_HOST=http://192.168.1.100:3000 ./scripts/seed-demo-data.sh users
# Seed patients only
API_HOST=http://192.168.1.100:3000 ./scripts/seed-demo-data.sh patients
# Seed everything
API_HOST=http://192.168.1.100:3000 ./scripts/seed-demo-data.sh
API_HOST is required. The default http://zynexa:3000 only resolves inside Docker containers.
When running from the host, always pass your server's IP or hostname.
| Variable | Default | Description |
|---|---|---|
API_HOST | http://zynexa:3000 (Docker only) | Zynexa base URL |
DRY_RUN | false | Preview mode — no records created |
Run Order
During a fresh deployment, the correct order is:
# Required
Supabase up → ctms-supabase-seed → Frappe up → ctms-init
# Optional (demo/QA only)
Zynexa up → ctms-user-seed → ctms-patient-seed
For re-runs after deployment:
# Re-seed required (safe — idempotent)
$DC --profile init run --rm ctms-supabase-seed
$DC --profile init run --rm ctms-init
# Re-seed optional demo data (all-in-one)
./scripts/seed-demo-data.sh
# Or individually
$DC --profile init run --rm ctms-user-seed
$DC --profile init run --rm ctms-patient-seed
Check Logs
docker logs ctms-init
docker logs ctms-supabase-seed
docker logs ctms-user-seed
docker logs ctms-patient-seed
For troubleshooting ctms-init failures, seed connection issues, and other provisioning problems, see Debugging & Troubleshooting.