mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
fix(setup): ensure step 69 runs without issues (#11503)
## Which problems are solved
https://github.com/zitadel/zitadel/pull/11484 introduced a regression
that causes the setup process to fail on existing Zitadel deployments.
This prevents users from upgrading to recent versions without
encountering setup failures.
## How the problems are solved
Setup step 69 has been corrected to properly handle existing deployment
configurations and prevent setup failures during initialization and
upgrades.
## Additional Context
introduced by
[7a41fe968b](https://github.com/zitadel/zitadel/commit/7a41fe968b9fcb69b378336740b74e5448c1ff81)
### Testing
- [x] Verified setup succeeds on fresh deployments
- [x] Verified setup succeeds on existing deployments
- [x] Verified migration from PostgreSQL 17 to 18 after running setup of
this version
This commit is contained in:
+19
-1
@@ -1,13 +1,31 @@
|
||||
DO
|
||||
$do$
|
||||
BEGIN
|
||||
-- Convert objects to logged first (if unlogged)
|
||||
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
|
||||
|
||||
-- Convert string_keys to logged (if unlogged)
|
||||
-- Drop the FK constraint first to allow converting cache.string_keys (and avoid loggedness-change restrictions involving the FK)
|
||||
IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.objects') AND relpersistence = 'u') THEN
|
||||
ALTER TABLE IF EXISTS cache.objects
|
||||
SET LOGGED;
|
||||
END IF;
|
||||
|
||||
-- Convert string_keys to logged (if unlogged)
|
||||
-- Drop the FK constraint first to avoid conflict with parent table conversion
|
||||
IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.string_keys') AND relpersistence = 'u') THEN
|
||||
ALTER TABLE IF EXISTS cache.string_keys
|
||||
DROP CONSTRAINT IF EXISTS fk_object;
|
||||
ALTER TABLE IF EXISTS cache.string_keys
|
||||
SET LOGGED;
|
||||
ALTER TABLE IF EXISTS cache.string_keys
|
||||
ADD CONSTRAINT fk_object
|
||||
FOREIGN KEY(cache_name, object_id)
|
||||
REFERENCES cache.objects(cache_name, id)
|
||||
ON DELETE CASCADE;
|
||||
END IF;
|
||||
|
||||
CREATE UNLOGGED TABLE IF NOT EXISTS cache.objects_default
|
||||
|
||||
Reference in New Issue
Block a user