formbricks-authzed-prepare; verify that executable in the selected release image before maintenance.
An upgrade from v5 to v6 first needs the dependencies in 6.0: Upgrade guide.
Preparation contract
- Run only the selected target image, with
AUTHZED_CONSISTENCY=fully_consistent. - The command checks the configuration and SpiceDB health, runs the app’s database migrations, prepares the permission schema, processes pending permission updates, repairs relationships and verifies the result.
- A different non-empty schema is blocked. Review
formbricks-authzed schema checkand the release’s schema changes before passing--expected-current-digest <remoteDigest>. - Exit
0andupgrade_preparedpermit the next deployment step. Any nonzero result keeps maintenance active.
What runs where
You run the maintenance steps: stopping the app and workers, pausing controllers, taking backups and restarting. The preparation command in the release image runs the database migrations and prepares the permission data.formbricks-authzed-prepare does not stop anything, take backups or restart services for you. The
--backup-confirmed and --writers-stopped flags are your confirmation that you’ve done those steps;
the command doesn’t check them. Do them first.
The command reuses the image’s existing migration runner and formbricks-authzed upgrade prepare and
upgrade check implementations. It does not automatically prune unexplained relationships.
Before the maintenance window
- Rehearse with an isolated copy of the installation. Measure migrations, backfill, verification, and restoration time; use those measurements to communicate the maintenance window.
- Pin the target Formbricks image by digest and the matching chart/Compose files. Preserve the current images, chart, values, secrets, and volume names. Do not combine this change with a PostgreSQL major upgrade, a storage migration, or unrelated Hub/Cube changes.
- Treat the Helm chart version and application image version as separate pins. A chart-only patch can
keep the same Formbricks
appVersion; verify both values and the rendered image before upgrading. - Prepare private SpiceDB connectivity, dedicated datastore credentials, its reviewed version, and completed datastore migrations. Retain existing operator ownership; never install a second operator over an existing cluster-wide operator. See SpiceDB operations.
Docker and one-click
Keep the same Compose project name, database images, and volumes. Prepare a target Compose file that retains customized SMTP, storage, networking, and Traefik settings. Pinformbricks,
formbricks-migrate, authzed-ops, and authzed-initialize to the same target image digest. Do not copy a
fresh-install Compose file over an existing installation without reviewing those differences.
After stopping the old project’s writers and verifying external writers/controllers are stopped,
start only the required infrastructure from the reviewed target configuration. Never use down -v.
With infrastructure already healthy, run the existing operations service without starting dependencies:
--project-name, --env-file, and -f options when customized. The operator service
must receive the application database URL, migration credentials when different, and the six AuthZed
client variables. The distributed default uses the bundled PostgreSQL database; customize it when your
installation uses a managed database. No database or SpiceDB port needs public exposure.
For a pre-provisioned external SpiceDB database, apply the release-matched
external Compose override before starting
spicedb-migrate or running this preparation. Keep COMPOSE_FILE in .env so validation, preparation, checks,
and cutover all use the same override; if you pass -f, specify both files in the same order every time. Its URI
and any private CA mount must reach both SpiceDB migration and
runtime services. Confirm docker compose config --services omits authzed-db-bootstrap, then use
docker compose ps -a to verify a completed migration and healthy SpiceDB. The database administrator provisions
the database and scoped login once, outside Compose; no administrator URL belongs in the application stack.
Include the external SpiceDB database in the coordinated backup before preparation and in the rollback plan.
After successful preparation, a one-click installation also sets
FORMBRICKS_AUTHZED_V6_MIGRATION_ACKNOWLEDGED=true before its explicit v6 update. Do not invoke an
unattended update or move a floating image tag until the release-specific installation tests pass.
Helm and GitOps
Prepare SpiceDB before the application upgrade. Keep the current database/storage settings and existing Secrets. During maintenance, use an explicit, temporary Kubernetes Job with the target Formbricks image, the same database/AuthZed environment bindings, and this command:formbricks-prepare-job.yaml. Set the image digest, and add resource limits, imagePullSecrets and
network policy if your cluster needs them. Don’t make the root filesystem read-only: the migrations write to
the container. For an external SpiceDB, set AUTHZED_ENDPOINT to its address and AUTHZED_INSECURE to "false".
Preparation uses these settings:
DATABASE_URLAUTHZED_ENABLED=true,AUTHZED_ENDPOINT,AUTHZED_TOKEN,AUTHZED_SYSTEM_KEY,AUTHZED_INSECURE, andAUTHZED_CONSISTENCY=fully_consistentWEBAPP_URL, in every case. Preparation runs the database migrations, and the OAuth resource-link data migration (first released in 5.4.0) derives each MCP OAuth client’s resource link from it. If you upgrade from before 5.4.0 and have MCP OAuth clients, preparation stops withupgrade_database_migration_failedwhenWEBAPP_URLis missing.
MIGRATE_DATABASE_URL as well as DATABASE_URL; the target image’s migration runner uses it when set. If
the configuration is still incomplete, the Job reports upgrade_configuration_invalid with the names of the
variables to fix.
Wait for Job completion and inspect its sanitized result before running helm upgrade or resuming an
Argo CD/Flux reconciliation. Preparation is not a Helm migration hook or a permanent chart component.
Delete the Job and any temporary environment Secret after the upgrade is done.
When the permission schema changes
Some minor releases change the permission schema, for example 6.0 → 6.1. Preparation then refuses to replace the existing schema until you confirm which one you’re replacing:- Run the same Job with
command: ["formbricks-authzed"]andargs: ["schema", "check"], using the target image, and a different name such asformbricks-v6-schema-check. It exits with code2(drifted), which is expected. - Copy the
remoteDigestvalue from its log. - Run the preparation Job with the digest added:
args: ["--backup-confirmed", "--writers-stopped", "--expected-current-digest", "<remoteDigest>"]. TheremoteDigestvalue already starts withsha256:; copy it as it is.
docker compose --profile authzed-ops run --rm --no-deps authzed-ops schema check, then add
--expected-current-digest <remoteDigest> to the preparation command. Patch releases never change the schema.
Exit checklist
Keep maintenance active until all of these are true:formbricks-authzed-prepareexited0, including its two clean full audits, and the v6 migration acknowledgement is set only for this prepared upgrade.- The pods run the target image, and a fresh
formbricks-authzed upgrade checkexits0. - Allowed and denied users, a scoped API key, organization/workspace lists, and a grant revocation work from a fresh browser session; an old tab recovers after a hard refresh.
Results and recovery
Success prints one JSON result and exits0:
2, without a restartRequired field. It never authorizes restarting workloads,
including when arguments were rejected before any work ran. The code identifies the failed step:
A blocked result can carry more fields, never values from your data:
"reason":"timeout"andtimeoutSeconds: the step ran out its time limit. It did not report a failure, so the code names the step, not a problem in it. Raise the limit and run preparation again.causeandretryable: the step’s own error code, such asauthzed_unavailable, and whether that error is transient. Retry a"retryable":trueresult once its cause, such as SpiceDB availability, has recovered.
FORMBRICKS_AUTHZED_PREPARE_STEP_TIMEOUT_SECONDS (60 to 86400) to change
it. The graph step rewrites every organization’s relationships and then audits them all, so its runtime grows
with the number of organizations. Newer images audit several organizations concurrently; an older sequential
run took about 35 minutes for 50,000 organizations. Size the limit from your own rehearsal, and keep the Job’s activeDeadlineSeconds above the sum of its steps: a Job deadline stops the
container before the wrapper can print a result. Interrupted containers can exit with a signal code rather
than JSON; any nonzero exit remains blocked.
The command never restarts a workload on success, failure, or interruption. Retry preparation with the
same image after correcting the cause, provided the interrupted migration is safe to rerun. Never mark
a failed Prisma migration applied without investigating it.
Diagnose migration failures privately
The wrapper deliberately does not offer raw output in shared Job logs: migration errors can contain credentials, SQL, or customer identifiers. In a restricted PostgreSQL operator session, inspect failed Prisma migration records in_prisma_migrations (migration_name, started_at, finished_at,
rolled_back_at, and logs). Treat logs as sensitive; do not paste it into CI, tickets, or Slack.
For failures before Prisma records the attempt, check connectivity and permissions in that restricted
session. If a migration must be retried, first establish whether partial changes need repair, then use
the target image’s node /home/nextjs/packages/database/dist/scripts/apply-migrations.js under maintenance.
Capture any diagnostic output only in operator-controlled storage; never enable it on normal startup.
If a migration fails shows how to find the real error,
check what the failed migration left behind, and clear its failed record before retrying.
After database changes, helm rollback or changing the image is not necessarily a safe rollback.
Remain in maintenance and either complete the v6 preparation or restore the coordinated backup and
matching v5 images/configuration. Resuming writes before restoration risks losing those new writes.