Upgrading, PITR Backups, and Bundle Portability
Upgrades across the LatticeDX 0.4.x (0.4.2) release line follow a deterministic sequence: verify SHA-256 and Point-in-Time Recovery (PITR) backups first, rehearse migrations against an isolated runtime, rebuild and enable the 7 host-mounted plugins, and use latticedx.solution-bundle/v3 for portable GitOps promotion across environments.
1. Mandatory Pre-Upgrade Backups and PITR Verification
Never rebuild plugins, recreate containers, or run database migrations without a verified backup manifest and confirmed WAL archiving readiness. LatticeDX ships four complementary recovery scripts scoped from individual databases to full-stack bundles:
| Parameter | Type | Default | Description |
|---|---|---|---|
scripts/stack-recovery.mjs | Full Stack | output/backups/stack/stack-<id> | Snapshots all 7 stateful components (nocobase-db, uploads, keycloak, orion-mongo, n8n, lattice-db, engine-objects) and inspects WAL archive readiness. |
scripts/pitr-backup.mjs | PITR / WAL | wal-g | pgbackrest | local-gz | Validates PITR configuration (check-config), builds base backups, lists restore points, and generates ISO-8601 restore plans. |
scripts/native-database-recovery.mjs | nocobase-db | output/backups/native/ | Creates a custom-format pg_dump of the nocobase database with per-table MD5 inventory fingerprints and rehearses restore. |
scripts/backup-core.mjs | lattice-db | output/backups/ | Dumps and rehearses restoration of the core lattice Fastify database into an ephemeral fixture database. |
Run PITR validation and capture a full-stack backup before starting any maintenance window:
# 1. Validate PITR WAL archiving readiness (wal-g / pgbackrest / local-gz)
node scripts/pitr-backup.mjs check-config --backend=local-gz --allow-unencrypted-local
# 2. Preview base-backup plan (append --execute to run directly)
node scripts/pitr-backup.mjs base-backup --backend=wal-g
# 3. Capture full 7-component stack backup with SHA-256 manifest
pnpm backup:stackFail-Closed PITR Key Enforcement
scripts/pitr-backup.mjs rejects wal-g or pgbackrest targets unless repository encryption keys (WALG_LIBSODIUM_KEY / WALG_PGP_KEY or PGBACKREST_REPO1_CIPHER_PASS) are configured, unless --allow-unencrypted-local is explicitly passed for local non-production archives. Local PITR_WAL_DIR archives enforce 0700 directory permissions and umask 077 gzip output.
2. Isolated Upgrade Rehearsal (native-rehearsal.yml)
Before applying changes to infra/compose/prod.yml, test plugin builds and schema migrations using infra/compose/native-rehearsal.yml (name: lattice-native-rehearsal). It launches an isolated nocobase-db (pgvector:0.8.1-pg16) and nocobase (2.2.50) pair bound strictly to 127.0.0.1:13001 with zero production volumes or public listeners:
docker compose -f infra/compose/native-rehearsal.yml up -d --wait
docker compose -f infra/compose/native-rehearsal.yml exec -T nocobase yarn nocobase upgrade
# Tear down ephemeral rehearsal containers and volumes
docker compose -f infra/compose/native-rehearsal.yml down -v3. Runtime and 7-Plugin Upgrade Workflow
Whether upgrading a local workspace (nocobase.yml) or production (prod.yml), the sequence follows four steps: backup, host-side plugin build, nocobase container recreation, and yarn nocobase upgrade.
Automated Local Workspace Upgrade (scripts/install-workspace.mjs)
Running pnpm workspace:install executes a guarded upgrade loop against infra/compose/nocobase.yml:
- Streams a custom-format
pg_dumpofnocobaseintooutput/backups/nocobase-before-workspace-<uuid>.dumpalongside a.jsonSHA-256 manifest, aborting immediately if the dump fails. - Restores locked dependencies for
plugin-enterprise-auth(npm ci --ignore-scripts --no-audit --no-fund) and builds all 7 plugins on the host. - Recreates the
nocobasecontainer (up -d --no-deps --force-recreate nocobase) and waits for/api/app:getLangto return HTTP 200. - Packs each plugin offline (
npm pack --offline --ignore-scripts), runsyarn nocobase pm addandyarn nocobase pm enable, and verifies viayarn nocobase pm listthat all 7@latticedx/*packages areenabled: trueat0.4.2.
Production Upgrade Runbook (infra/compose/prod.yml)
Execute the following steps during a production maintenance window:
# 1. Pull target release and rebuild all 7 host-mounted plugins
pnpm install --frozen-lockfile
npm ci --prefix plugins/nocobase/plugin-enterprise-auth --ignore-scripts --no-audit --no-fund
node plugins/nocobase/action-bridge/build.mjs
node plugins/nocobase/plugin-lattice-foundation/scripts/build.mjs
node plugins/nocobase/plugin-enterprise-auth/build.mjs
node plugins/nocobase/plugin-dxos-para/build.mjs
node plugins/nocobase/plugin-dxos-blocks/build.mjs
node plugins/nocobase/plugin-dxos-studio/build.mjs
node plugins/nocobase/plugin-dxos-ai/build.mjs
# 2. Recreate nocobase container with updated read-only plugin mounts
docker compose --env-file .env.prod -f infra/compose/prod.yml up -d --no-deps --force-recreate nocobase
# 3. Apply host and plugin schema migrations
docker compose --env-file .env.prod -f infra/compose/prod.yml exec -T nocobase yarn nocobase upgradeIf the RLS verification query returns a count greater than 0, inspect the migration logs for plugin-lattice-foundation and plugin-dxos-ai before restoring public traffic.
4. 0.4.x Compatibility and NocoBase 2.2.50 Host Contract
LatticeDX locks the monorepo and all 7 @latticedx/* plugins at 0.4.2 within the 0.4.x pre-1.0 release line. Compatibility boundaries are enforced continuously in CI:
| Component | Version Contract | Compatibility Boundary |
|---|---|---|
| Platform & 7 Plugins | 0.4.2 | All 7 packages declare "version": "0.4.2" and "sdkProvidedByHost": true. |
| NocoBase Host Runtime | 2.2.50 (supportedVersions: ["2.2.x"]) | Runs from pinned digest @sha256:04b75164936e7314ef74d82844bc56c9f34ed7ff1ca976ca53ffac2d3c88d777, supplying react: 18.2.0, react-dom: 18.2.0, antd: 5.24.2, and @nocobase/* host packages. |
| PostgreSQL & pgvector | 16.16 + pgvector 0.8.1 | Preserves vector indexes (8..8192 dimensions) and FORCE ROW LEVEL SECURITY enforcement under nocobase_app. |
| Keycloak / APISIX / Valkey | 26.8.2 / 3.19.0 / 8.1 | Realm lattice, PKCE S256 flows, and Valkey DB 0/1/2 partitioning remain stable across 0.4.x. |
Within the 0.4.x line, dynamic latticeCustom* tables and latticeUiSnapshots records remain forward-compatible across patch updates. Any breaking schema change in future minor releases ships with explicit migration steps.
5. Configuration Portability with Solution Bundle v3
When promoting portals, business roles, LatticeFlow v2 automations, DMN decision tables, AI profiles, and latticeCustom* collections across dev, staging, and production environments (or migrating tenants into a freshly upgraded cluster), export and import via Solution Bundle v3 (latticedx.solution-bundle/v3).
A latticedx.solution-bundle/v3 payload contains metadata (schemaVersion, platformVersion: '0.4.2', organizationId, exportedAt, contentSha256) and 8 top-level sections: roles, portals, workflows, aiProfiles, customCollections, connectors, routesAndBlocks (routes, flowModels), and governance (decisionTables, slaPolicies, incidentRules, automationRules, webhookSubscriptions).
Import safety controls are enforced server-side across three rules:
| Security Control | Server-Side Enforcement |
|---|---|
| Multi-version v1 / v2 / v3 ingestion | Accepts v1, v2, and v3 bundles while stripping secret keys (SECRET_KEY_RE, CONNECTOR_SECRET_KEYS) so credentials never leak across environments. |
| Privilege and injection blocking | Rejects root, admin, and ldx_admin role definitions, wildcard permission snippets, custom code keys, XSS payloads, and prototype pollution keys. |
Safe dryRun: true default and snapshot | solutionBundleImport defaults to dryRun: true; live imports (dryRun: false) first snapshot pre-import state into latticeUiSnapshots (portalSlug: '__gitops_bundle__') for atomic restoration via solutionBundleRollback. |
/api/dxosStudio:solutionBundleExport/api/dxosStudio:solutionBundleDiff/api/dxosStudio:solutionBundleImport/api/dxosStudio:solutionBundleRollback# Export a Solution Bundle v3 from the source organization
curl -fsS -H "Authorization: Bearer <TOKEN>" \
"https://<LATTICE_DOMAIN>/api/dxosStudio:solutionBundleExport" -o bundle-v3.json
# Diff against the target environment before applying
curl -fsS -X POST \
-H "Authorization: Bearer <TARGET_TOKEN>" \
-H "Content-Type: application/json" \
-d @bundle-v3.json \
"https://<TARGET_DOMAIN>/api/dxosStudio:solutionBundleDiff"6. Emergency Rollback on Upgrade Failure
If a container recreation or schema migration fails mid-rollout:
- Stop incoming traffic to
nocobaseat the Caddy or APISIX layer. - If the regression occurred during a Solution Bundle v3 promotion, invoke
POST /api/dxosStudio:solutionBundleRollbackto restore the pre-import UI and route snapshot. - If
nocobase-dbschema migrations failed partway through, restore the verifiedstack-recovery.mjsbundle or recover via PITR to the timestamp captured immediately beforeyarn nocobase upgradeusing the runbook in Backup and PITR.
