Migrations
Schema migrations with branching, rollback, and CI/CD integration
Overview
Run schema migrations safely using database branches. Test changes in isolation before applying to production.
Workflow
1. Create a branch
Create a branch via the API to isolate your migration:
bash
curl -X POST https://api.scalix.world/api/v1/tenants/$TENANT_ID/timelines/$TIMELINE_ID/branch \
-H "Authorization: Bearer $SCALIX_API_KEY"2. Apply migrations on the branch
bash
scalix-cloud db query "CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
total DECIMAL(10,2),
created_at TIMESTAMPTZ DEFAULT NOW()
)"3. Test
Run your application against the branch to verify everything works.
4. Merge
Apply the same migration to production:
bash
scalix-cloud db query "CREATE TABLE orders (...)"5. Clean up
Delete the branch via the API when done.
CI/CD Integration
Use branches in your CI pipeline:
yaml
# .github/workflows/test.yml
jobs:
test:
steps:
- name: Create test branch
run: |
curl -X POST https://api.scalix.world/api/v1/tenants/$TENANT_ID/timelines/$TIMELINE_ID/branch \
-H "Authorization: Bearer $SCALIX_API_KEY"
- name: Run migrations
run: scalix-cloud db query "CREATE TABLE orders (...)"
- name: Run tests
run: npm testMigration from Other Platforms
Import data from existing databases:
bash
scalix-cloud migrate db import --source postgres://user:pass@host:5432/mydbImports from a live PostgreSQL source (via pg_dump → pg_restore). The
--source must be a reachable PostgreSQL connection string.