Skip to main content

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.

Quick Reference

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 vs Optional

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
VariableDefaultDescription
DATABASE_URLfrom .env.productionPostgreSQL connection string
CTMS_SEED_DRY_RUNfalseSet to true to preview without applying

2. Frappe Init (ctms-init)

Provisions Frappe with CTMS-specific configuration across 5 stages:

StageDescriptionRecords
1Custom DocTypes (4 dependency phases)34
2Custom Fields on built-in DocTypes15 fields
3RBAC — Roles, Resources, Actions, Permissions, Navigation539
4Master / Reference Data — Frappe base data, Item Groups, study-design lookups, drugs, sites, events142
5Default Healthcare Practitioner1

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
VariableDefaultDescription
FRAPPE_URLfrom .env.productionFrappe backend URL
FRAPPE_API_TOKENfrom .env.productionAPI token (key:secret)
CTMS_INIT_STAGES1,2,3,4,5Comma-separated stages to run
CTMS_INIT_DRY_RUNfalsePreview mode
CTMS_INIT_LOG_LEVELINFOLog verbosity (DEBUG, INFO, WARNING)
PRACTITIONER_FIRST_NAMEMaryStage 5 practitioner first name
PRACTITIONER_LAST_NAMEWilliamsStage 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
UserRole
kiran.v@zynomi.comPlatform Administrator
michael.x@zynomi.comStudy Coordinator
roshini.s@zynomi.comStudy Designer
peter.p@zynomi.comPrincipal 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
Why optional?

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.

FieldExample Values
NamesSarah Chen, James Rodriguez, Emily Thompson, …
Emails*@subject.com
PasswordDefault demo password
RolePatient
GenderMale / Female
DOBRange: 1955–2000
VariableDefaultDescription
API_HOSThttp://zynexa:3000Zynexa base URL (Docker internal)
CSV_FILE/app/data/synthetic/syn_patients.csvPath to patient CSV inside container
DRY_RUNfalseSet 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
caution

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.

VariableDefaultDescription
API_HOSThttp://zynexa:3000 (Docker only)Zynexa base URL
DRY_RUNfalsePreview 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.