Files
zitadel/cmd/setup/69.sql
T
7a41fe968b 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]>
2026-02-03 16:23:24 +00:00

20 lines
623 B
SQL

DO
$do$
BEGIN
IF EXISTS (SELECT 1 FROM pg_class WHERE oid = 'cache.objects'::REGCLASS AND relpersistence = 'u') THEN
ALTER TABLE IF EXISTS cache.objects
SET LOGGED;
END IF;
IF EXISTS (SELECT 1 FROM pg_class WHERE oid = 'cache.string_keys'::REGCLASS AND relpersistence = 'u') THEN
ALTER TABLE IF EXISTS cache.string_keys
SET LOGGED;
END IF;
CREATE UNLOGGED TABLE IF NOT EXISTS cache.objects_default
PARTITION OF cache.objects DEFAULT;
CREATE UNLOGGED TABLE IF NOT EXISTS cache.string_keys_default
PARTITION OF cache.string_keys DEFAULT;
END
$do$