OpenMetadata/bootstrap/sql/migrations/native/1.12.0/postgres/schemaChanges.sql
Sriharsha Chintalapani 69ef1371bc
Rules library (#24748)
* Add DQ Rules Library

* Add DQ Rules Library - Add Tests and enable testDefinitions through APIs to list

* Add DQ Rules Library - Add Tests and enable testDefinitions through APIs to list

* Add DQ Rules Library - Add Tests and enable testDefinitions through APIs to list

* Update generated TypeScript types

* Add DQ Rules Library - Add Tests and enable testDefinitions through APIs to list

* Add DQ Rules Library - Add Tests and enable testDefinitions through APIs to list

* Update generated TypeScript types

* Refactor tests to use toStrictEqual for string comparisons and improve consistency

- Updated various test files to replace `toBe` with `toStrictEqual` for string assertions in ImportStatus, SummaryCard, TabsLabel, and others.
- Enhanced regex tests to ensure accurate validation of entity names and tags.
- Added new translations for test platform warnings in en-us.json.
- Improved utility tests for alerts, authentication, CSV handling, and task messages to use `toEqual` for better clarity.

* Refactor TestDefinitionForm and TestDefinitionList components to use updated API methods and improve SQL expression handling

* Enhance TestDefinitionList component with permission checks for edit and delete actions, and update tests to reflect changes in permission handling

* Remove debug log from handleSubmit in TestDefinitionForm component

* Add permission loading state and enhance permission handling in TestDefinitionList component

* Update generated TypeScript types

* Update generated TypeScript types

* Update generated TypeScript types

* fix build failure

* Revert "Update generated TypeScript types"

This reverts commit 67b062216f.

* Enhance TestDefinitionForm and TestDefinitionList components with improved UI and pagination handling

* fix: update RulesLibrary tests and enhance TestDefinitionForm styling

* fix: Enhance TestDefinitionForm with error handling and improved UX

* fix: Update test definition handling and improve rendering in TestDefinitionList

* fix: Refactor TestDefinitionPermissions tests for improved permission checks and API context handling

* fix: Update system test definition retrieval to use findLast for improved accuracy

* feat: Add end-to-end tests for Rules Library and Test Definition Permissions

* fix: Update edit button visibility check to use beDisabled for better clarity

* fix: Refactor response handling in TestDefinitionPermissions tests for improved reliability

* move migrations execution order

* fix: remove existing columns

* style: remove migration extra line break

* chore: fix migration

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
Co-authored-by: TeddyCr <teddy.crepineau@gmail.com>
2026-01-14 08:12:30 +01:00

68 lines
2.7 KiB
SQL

-- Update ApplicationBotRole to include Trigger operation
UPDATE policy_entity
SET json = jsonb_set(json::jsonb, '{rules,0,operations}', (json->'rules'->0->'operations')::jsonb || '["Trigger"]'::jsonb)
WHERE name = 'ApplicationBotPolicy'
AND json->'rules'->0->'operations' IS NOT NULL
AND NOT (json->'rules'->0->'operations' @> '"Trigger"'::jsonb);
-- Create table for persisted audit log events
CREATE TABLE IF NOT EXISTS audit_log_event (
id BIGSERIAL PRIMARY KEY,
change_event_id UUID NOT NULL,
event_ts BIGINT NOT NULL,
event_type VARCHAR(32) NOT NULL,
user_name VARCHAR(256),
actor_type VARCHAR(32) DEFAULT 'USER',
impersonated_by VARCHAR(256) DEFAULT NULL,
service_name VARCHAR(256) DEFAULT NULL,
entity_type VARCHAR(128),
entity_id UUID,
entity_fqn VARCHAR(768),
entity_fqn_hash VARCHAR(768),
event_json TEXT NOT NULL,
created_at BIGINT DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000)::BIGINT
);
-- Add indexes for efficient filtering
CREATE INDEX IF NOT EXISTS idx_audit_log_actor_type_ts ON audit_log_event (actor_type, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_service_name_ts ON audit_log_event (service_name, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_created_at ON audit_log_event (created_at);
-- Add enabled field to test_definition table for Rules Library feature
-- This allows administrators to enable/disable test definitions in the rules library
-- Add generated column for enabled field with default true for existing rows
ALTER TABLE test_definition
ADD COLUMN IF NOT EXISTS enabled BOOLEAN GENERATED ALWAYS AS (
COALESCE((json ->> 'enabled')::boolean, true)
) STORED;
-- Add index for filtering enabled/disabled test definitions
CREATE INDEX IF NOT EXISTS idx_test_definition_enabled ON test_definition(enabled);
-- Set all existing test definitions to enabled by default
UPDATE test_definition
SET json = jsonb_set(json::jsonb, '{enabled}', 'true'::jsonb, true)::json
WHERE json ->> 'enabled' IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_audit_log_event_change_event_id
ON audit_log_event (change_event_id);
CREATE INDEX IF NOT EXISTS idx_audit_log_event_ts
ON audit_log_event (event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_event_user_ts
ON audit_log_event (user_name, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_event_entity_hash_ts
ON audit_log_event (entity_fqn_hash, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_actor_type_ts
ON audit_log_event (actor_type, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_service_name_ts
ON audit_log_event (service_name, event_ts DESC);
CREATE INDEX IF NOT EXISTS idx_audit_log_created_at
ON audit_log_event (created_at);