Fix: PostgreSQL migration immutability issue with databaseSchemaHash … (#23606)

* Fix: PostgreSQL migration immutability issue with databaseSchemaHash column

* Fix: PostgreSQL migration immutability issue with databaseSchemaHash column
This commit is contained in:
sonika-shah 2025-09-29 17:07:09 +05:30 committed by GitHub
parent b489112bdd
commit 92c30f2a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 -- Optimize table listing queries by indexing the schema hash prefix
ALTER TABLE table_entity ALTER TABLE table_entity
ADD COLUMN databaseSchemaHash VARCHAR(768) ADD COLUMN IF NOT EXISTS databaseSchemaHash VARCHAR(768)
GENERATED ALWAYS AS ( 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; ) 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); ON table_entity (deleted, databaseSchemaHash, name, id);
-- Optimize stored procedure listing queries by indexing the schema hash prefix -- Optimize stored procedure listing queries by indexing the schema hash prefix
ALTER TABLE stored_procedure_entity ALTER TABLE stored_procedure_entity
ADD COLUMN databaseSchemaHash VARCHAR(768) ADD COLUMN IF NOT EXISTS databaseSchemaHash VARCHAR(768)
GENERATED ALWAYS AS ( 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; ) STORED;
DROP INDEX IF EXISTS idx_stored_procedure_entity_deleted_name_id; 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); ON stored_procedure_entity (deleted, databaseSchemaHash, name, id);