Skip to content

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:

Pre-Upgrade Backup and Recovery Verification Scripts
ParameterTypeDefaultDescription
scripts/stack-recovery.mjs
Full Stackoutput/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 / WALwal-g | pgbackrest | local-gzValidates PITR configuration (check-config), builds base backups, lists restore points, and generates ISO-8601 restore plans.
scripts/native-database-recovery.mjs
nocobase-dboutput/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-dboutput/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:

bash
# 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:stack

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

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

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

  1. Streams a custom-format pg_dump of nocobase into output/backups/nocobase-before-workspace-<uuid>.dump alongside a .json SHA-256 manifest, aborting immediately if the dump fails.
  2. Restores locked dependencies for plugin-enterprise-auth (npm ci --ignore-scripts --no-audit --no-fund) and builds all 7 plugins on the host.
  3. Recreates the nocobase container (up -d --no-deps --force-recreate nocobase) and waits for /api/app:getLang to return HTTP 200.
  4. Packs each plugin offline (npm pack --offline --ignore-scripts), runs yarn nocobase pm add and yarn nocobase pm enable, and verifies via yarn nocobase pm list that all 7 @latticedx/* packages are enabled: true at 0.4.2.

Production Upgrade Runbook (infra/compose/prod.yml) ​

Execute the following steps during a production maintenance window:

bash
# 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 upgrade

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

ComponentVersion ContractCompatibility Boundary
Platform & 7 Plugins0.4.2All 7 packages declare "version": "0.4.2" and "sdkProvidedByHost": true.
NocoBase Host Runtime2.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 & pgvector16.16 + pgvector 0.8.1Preserves vector indexes (8..8192 dimensions) and FORCE ROW LEVEL SECURITY enforcement under nocobase_app.
Keycloak / APISIX / Valkey26.8.2 / 3.19.0 / 8.1Realm 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 ControlServer-Side Enforcement
Multi-version v1 / v2 / v3 ingestionAccepts v1, v2, and v3 bundles while stripping secret keys (SECRET_KEY_RE, CONNECTOR_SECRET_KEYS) so credentials never leak across environments.
Privilege and injection blockingRejects root, admin, and ldx_admin role definitions, wildcard permission snippets, custom code keys, XSS payloads, and prototype pollution keys.
Safe dryRun: true default and snapshotsolutionBundleImport defaults to dryRun: true; live imports (dryRun: false) first snapshot pre-import state into latticeUiSnapshots (portalSlug: '__gitops_bundle__') for atomic restoration via solutionBundleRollback.
GET/api/dxosStudio:solutionBundleExport
Bearer JWT | ldx_pat_*write
Exports the current organization configuration as a latticedx.solution-bundle/v3 JSON document with a contentSha256 digest.
POST/api/dxosStudio:solutionBundleDiff
Bearer JWT | ldx_pat_*write
Computes a structural diff between an incoming Solution Bundle v3 payload and the target organization state.
POST/api/dxosStudio:solutionBundleImport
Bearer JWT | ldx_pat_*write
Validates (dryRun: true default) or applies v1/v2/v3 bundles after capturing a rollback snapshot.
POST/api/dxosStudio:solutionBundleRollback
Bearer JWT | ldx_pat_*write
Reconciles created or modified artifacts and restores the pre-import __gitops_bundle__ snapshot.
bash
# 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:

  1. Stop incoming traffic to nocobase at the Caddy or APISIX layer.
  2. If the regression occurred during a Solution Bundle v3 promotion, invoke POST /api/dxosStudio:solutionBundleRollback to restore the pre-import UI and route snapshot.
  3. If nocobase-db schema migrations failed partway through, restore the verified stack-recovery.mjs bundle or recover via PITR to the timestamp captured immediately before yarn nocobase upgrade using the runbook in Backup and PITR.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)