From 92c30f2a0a2c1e3e69bd5a23396cb9eae6d3c033 Mon Sep 17 00:00:00 2001 From: sonika-shah <58761340+sonika-shah@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:07:09 +0530 Subject: [PATCH] =?UTF-8?q?Fix:=20PostgreSQL=20migration=20immutability=20?= =?UTF-8?q?issue=20with=20databaseSchemaHash=20=E2=80=A6=20(#23606)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: PostgreSQL migration immutability issue with databaseSchemaHash column * Fix: PostgreSQL migration immutability issue with databaseSchemaHash column --- .../native/1.10.0/postgres/schemaChanges.sql | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bootstrap/sql/migrations/native/1.10.0/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.10.0/postgres/schemaChanges.sql index ebc8508bf94..b5fd8441d0b 100644 --- a/bootstrap/sql/migrations/native/1.10.0/postgres/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.10.0/postgres/schemaChanges.sql @@ -50,22 +50,32 @@ CREATE INDEX IF NOT EXISTS idx_notification_template_provider ON notification_te -- Optimize table listing queries by indexing the schema hash prefix ALTER TABLE table_entity -ADD COLUMN databaseSchemaHash VARCHAR(768) +ADD COLUMN IF NOT EXISTS databaseSchemaHash VARCHAR(768) GENERATED ALWAYS AS ( - concat_ws('.', split_part(fqnhash, '.', 1), split_part(fqnhash, '.', 2), split_part(fqnhash, '.', 3)) + rtrim( + split_part(fqnhash, '.', 1) || '.' || + split_part(fqnhash, '.', 2) || '.' || + split_part(fqnhash, '.', 3), + '.' + ) ) STORED; -CREATE INDEX idx_table_entity_schema_listing +CREATE INDEX IF NOT EXISTS idx_table_entity_schema_listing ON table_entity (deleted, databaseSchemaHash, name, id); -- Optimize stored procedure listing queries by indexing the schema hash prefix ALTER TABLE stored_procedure_entity -ADD COLUMN databaseSchemaHash VARCHAR(768) +ADD COLUMN IF NOT EXISTS databaseSchemaHash VARCHAR(768) GENERATED ALWAYS AS ( - concat_ws('.', split_part(fqnhash, '.', 1), split_part(fqnhash, '.', 2), split_part(fqnhash, '.', 3)) + rtrim( + split_part(fqnhash, '.', 1) || '.' || + split_part(fqnhash, '.', 2) || '.' || + split_part(fqnhash, '.', 3), + '.' + ) ) STORED; DROP INDEX IF EXISTS idx_stored_procedure_entity_deleted_name_id; -CREATE INDEX idx_stored_procedure_schema_listing +CREATE INDEX IF NOT EXISTS idx_stored_procedure_schema_listing ON stored_procedure_entity (deleted, databaseSchemaHash, name, id);