Upgrading a self-hosted instance
When you run PotaLab Base with the Community Docker Compose files, a one-shot service called init-upgrade brings every database to the version shipped in the new image. You no longer run any SQL by hand.
Upgrade steps
Section titled “Upgrade steps”- Read the changelog, especially the Breaking section.
- Back up:
pg_dumpthe platform and project databases, and keep a copy of.env(it holdsBASE_MASTER_KEY). - Set the new
BASE_IMAGE_TAGin.env, then:
docker compose pulldocker compose up -ddocker compose logs init-upgradeinit-upgrade runs the new Postgres image against your existing volume and applies, in order: the cluster (roles and permissions), the platform and regional databases, every project database, and finally the template used for new projects. Each SQL file runs in its own transaction and is recorded in base_internal.schema_version, so a file that is already applied is skipped and running it again changes nothing.
Breaking changes
Section titled “Breaking changes”Migrations API: plan version 2, lost run lock is 409
Section titled “Migrations API: plan version 2, lost run lock is 409”POST .../database/migrations/plananswersplan_version: 2withitems[](one result per script) andcomplete. The top-level fields are unchanged. A script withCREATE INDEX CONCURRENTLYorCOMMITno longer fails the whole request with400 plan_unavailable: its item isnon_transactional, the scripts after it arenot_planned, andwould_applyisfalse. A script that fails is reported in its item instead of failing the request.migration_lock_lostis now409(was400).- A migration that is a single
CREATE/DROP INDEX CONCURRENTLYis now applied instead of refused (see Management API).
Exposed schemas allowlist (Data Router)
Section titled “Exposed schemas allowlist (Data Router)”The Data Router accepts only these names in db_schemas (API config or the static projects file):
public,apiandcore;app_<slug>(lower-case letters, digits and_, at most 40 characters afterapp_).
The list holds at most 50 entries, with no spaces and no duplicates. Any other schema name, which earlier versions accepted, now makes the router refuse the project at start with invalid db_schemas ....
To upgrade, rename the schema before the upgrade, then put the new name in db_schemas:
alter schema reports rename to app_reports;You can also move its objects into public, api or an app_ schema.
App roles: foreign_app_role warning
Section titled “App roles: foreign_app_role warning”The upgrade can print WARNING: foreign_app_role: objects of database <db> depend on app roles of other projects: .... It means objects in that database were granted to an app role of another project ("<other db>.app_x"), usually by hand. Nothing is removed, and the project keeps working. New grants of that kind are refused from now on.
To clean up, connect to that database as a superuser and revoke the listed role there:
REVOKE ALL ON ALL TABLES IN SCHEMA <schema> FROM "<other db>.app_x"(do the same for schemas, sequences and functions);DROP POLICYfor any policy written for it;ALTER ... OWNER TOfor any object it owns.
The security advisor of the project lists the role as foreign_app_role until no dependency is left.
Management API: PATCH merges nested sections key by key
Section titled “Management API: PATCH merges nested sections key by key”A PATCH that sends a nested section now changes only the keys it names. Earlier versions replaced the whole section, so a key you did not send was reset to its default. This applies to:
PATCH /v1/projects/{ref}/config/auth:mfa,passkeys,email_branding,rate_limits;PATCH /v1/projects/{ref}/config/rate-limits: each bucket, for exampleburst;PATCH /v1/projects/{ref}/config/realtime:limits;PATCH /v1/projects/{ref}/log-drains/{id}:s3;PATCHof an SSO provider (attribute_mapping) and of an OIDC provider (claim_mapping).
What a client has to change:
- To remove one key, send it as
null, for example{ "email_branding": { "footer_text": null } }. Leaving the key out keeps its stored value. - Lists and maps are still replaced as a whole. Send
[]to clear a list, and{}to empty a map:email_templates: {}resets every template, andattribute_mapping.extrais replaced. - To clear a whole section, send the section as
nullwhere the route allows it, for examplelimits: null.
A client that always sends the full section, like the dashboard, sees no difference.
Permission checks apply to the result, not to the keys you send. Returning a key to its default with null counts as a change:
- changing auth
rate_limitsneeds theadminrole,nullincluded; - lowering MFA (turning it off, or no longer requiring it for every user) now needs the
adminrole and is audited at high severity; - a patch that leaves the config invalid, such as
nullon a required key likemfa.enabled, is refused with400.
Two instances at once
Section titled “Two instances at once”The whole run holds a Postgres advisory lock (BASE_LOCK_INIT). If two stacks or two runners start at the same moment, the second waits, then finds everything already applied. Nothing is applied twice.
When something fails
Section titled “When something fails”The failing file is rolled back, init-upgrade exits with an error and core-api, data-router, realtime and functions do not start. The stack never runs on a half-upgraded schema. Read docker compose logs init-upgrade, fix the cause, and run docker compose up -d again. If you cannot fix it, restore from your backup and set the old tag back. Upgrades only move forward, there is no automatic downgrade.
Turning it off
Section titled “Turning it off”Set BASE_AUTO_UPGRADE=false in .env. init-upgrade then logs that it is skipped and exits successfully. You apply the SQL yourself with base-apply-cluster-init, base-apply-init <database> <platform|regional|project> and base-create-template inside the postgres container (see UPGRADE.md in the self-host repository).