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.

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
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:

StageDescription
1DocTypes
2Custom Fields
3RBAC (Roles & Permissions)
4Master Data
5Default 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
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

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

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