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.
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 three containers run under the Docker Compose init profile and are idempotent — existing records are skipped, so re-running is always safe.
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"
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 |
|---|---|
| 1 | DocTypes |
| 2 | Custom Fields |
| 3 | RBAC (Roles & Permissions) |
| 4 | Master Data |
| 5 | Default Healthcare Practitioner |
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
CTMS_INIT_STAGES=4,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 |
3. User Seed
Seeds 4 demo users into Zynexa via the signup API.
Prerequisite: Zynexa must be running and healthy.
$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
Run Order
During a fresh deployment, the correct order is:
Supabase up → ctms-supabase-seed → Frappe up → ctms-init → Zynexa up → ctms-user-seed
For re-runs after deployment:
# Re-seed everything (safe — idempotent)
$DC --profile init run --rm ctms-supabase-seed
$DC --profile init run --rm ctms-init
$DC --profile init run --rm ctms-user-seed
Troubleshooting
ctms-init Stage 5 fails with 417 error
Re-run ctms-init — it's idempotent, stages 1–4 skip automatically:
$DC --profile init run --rm ctms-init
ctms-user-seed fails to connect
Zynexa may still be starting. Wait 30 seconds and retry, or use the zynctl command which has built-in retry logic:
./zynctl.sh seed-users
Check logs from last run
docker logs ctms-init
docker logs ctms-supabase-seed
docker logs ctms-user-seed