fix(setup): ensure PostgreSQL 18 compatibility (#11484)

# Which Problems Are Solved

When starting Zitadel with Postgres version 18, setup fails with the
following error:

`level=error msg="migration failed" caller=".../cmd/setup/setup.go:373"
code=0A000 detail= error="ERROR: partitioned tables cannot be unlogged
(SQLSTATE 0A000)" hint= message="partitioned tables cannot be unlogged"
name=34_add_cache_schema severity=ERROR`

# How the Problems Are Solved

- Modify setup step 34 to ensure compatibility with PostgreSQL 18 by
changing the creation of the partitioned tables to`LOGGED` tables but
keep the partitions `UNLOGGED`.
- Added an additional setup step which alters the table persistence of
the partitioned tables to `LOGGED`.

# Additional Changes

- Bumped Postgres compatibility to version 18 in docs.
- Ensure default partitions for cache tables

## Additional Context

- closes https://github.com/zitadel/zitadel/issues/10712
- backport to v4
- migration from PostgreSQL version 17 to 18 was verified using
`pg_dumpall` and restoring the created backup file
- and new setups using PostgreSQL version 18 directly

---------

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Silvan
2026-02-03 16:23:24 +00:00
committed by GitHub
co-authored by Copilot
parent 6363ee0d0a
commit 7a41fe968b
7 changed files with 61 additions and 6 deletions
+2
View File
@@ -249,6 +249,7 @@ func Setup(ctx context.Context, config *Config, steps *Steps, masterKey string)
steps.s66SessionRecoveryCodeCheckedAt = &SessionRecoveryCodeCheckedAt{dbClient: dbClient}
steps.s67SyncMemberRoleFields = &SyncMemberRoleFields{dbClient: dbClient}
steps.s68TargetAddPayloadTypeColumn = &TargetAddPayloadTypeColumn{dbClient: dbClient}
steps.s69CacheTablesLogged = &CacheTablesLogged{dbClient: dbClient}
err = projection.Create(ctx, dbClient, eventstoreClient, config.Projections, nil, nil, nil)
logging.OnError(err).Fatal("unable to start projections")
@@ -303,6 +304,7 @@ func Setup(ctx context.Context, config *Config, steps *Steps, masterKey string)
steps.s64ChangePushPosition,
steps.s65FixUserMetadata5Index,
steps.s67SyncMemberRoleFields,
steps.s69CacheTablesLogged,
} {
setupErr = executeMigration(ctx, eventstoreClient, step, "migration failed")
if setupErr != nil {