causet migrations

Proposed: causet migrations is on the roadmap. In normal operation, DDL is applied automatically by the deployment process. The CLI commands are for manual and emergency use. See Roadmap.

Applies projection DDL from causet.projections.json to the tenant schema for a given platform/application/fork.


When You Need This

In normal operation, DDL is applied automatically when you deploy a release via the control plane — you do not need causet migrations apply for routine deployments.

Use causet migrations when:

  • A deployment failed partway through and DDL was partially applied
  • You need to apply a new IR to a fork without going through the release deploy UI
  • Debugging schema state in a test or staging environment
  • Emergency recovery after a schema drift was detected

causet migrations apply

Apply DDL from the active IR to the tenant schema.

causet migrations apply \
  --platform my-platform \
  --app concert-app \
  --fork main \
  --env production

What it does:

  1. Loads causet.projections.json from the active release for the fork
  2. Determines the target schema: {platformId}_{applicationId}_{forkId}
  3. Creates the schema if it does not exist
  4. For each projection: CREATE TABLE IF NOT EXISTS, ADD COLUMN IF NOT EXISTS, CREATE INDEX IF NOT EXISTS

DDL is additive only. Existing columns, tables, and data are never removed. See Schema Evolution for handling column removal.

Flags:

FlagDescription
--platform <p>Platform identifier (required)
--app <a>Application identifier (required)
--fork <f>Fork to target (required)
--env <name>Target environment
--dry-runPrint DDL statements without executing
--ir-path <path>Use a local causet.projections.json instead of the active release

Dry run example:

causet migrations apply \
  --platform my-platform \
  --app concert-app \
  --fork main \
  --env production \
  --dry-run

Output:

-- Schema: my_platform_concert_app_main
CREATE SCHEMA IF NOT EXISTS my_platform_concert_app_main;
 
-- Projection: user_following
CREATE TABLE IF NOT EXISTS my_platform_concert_app_main.user_following (
  user_id   TEXT NOT NULL,
  artist_id TEXT NOT NULL,
  followed_at BIGINT,
  PRIMARY KEY (user_id, artist_id)
);
CREATE INDEX IF NOT EXISTS idx_user_following_user_id
  ON my_platform_concert_app_main.user_following (user_id);

causet migrations status

Show pending vs applied migrations for a fork.

causet migrations status \
  --platform my-platform \
  --app concert-app \
  --fork main \
  --env production

Example output:

Schema: my_platform_concert_app_main

PROJECTION              TABLE                   STATUS
user_following          user_following          ✓ applied
artist_show_directory   artist_show_directory   ✓ applied
venue_stats             venue_stats             ✕ missing
user_concert_memory     user_concert_memory     ✓ applied (missing 1 index)

1 table missing, 1 table missing indexes.
Run 'causet migrations apply' to apply pending changes.

Limitations

  • Column removal is not supported. Removing a field from the DSL does not drop the column. See Schema Evolution for the manual process.
  • Primary key changes are not supported. A primary key change requires a new table, data migration, and swap. causet migrations apply will not attempt this.
  • Data migrations are not managed. This tool manages schema shape only — transforming existing data is outside its scope.

Exit Codes

CodeMeaning
0All migrations applied successfully
1One or more migrations failed
2Invalid arguments or missing configuration