OpenMetadata/bootstrap/sql/migrations/native/1.6.0/postgres/postDataMigrationSQLScript.sql
Teddy aa399dfd68
MINOR: move constraint update from schemaChanges to postDataMigration (#17801)
* fix: move constraint update from schemaChanges to postDataMigration

* fix: move index after column is created
2024-09-12 08:13:41 +02:00

18 lines
734 B
SQL

-- Add FQN and UUID to data_quality_data_time_series records
UPDATE data_quality_data_time_series dqdts
SET json = jsonb_set(
jsonb_set(dqdts.json::jsonb, '{testCaseFQN}', tc.json->'fullyQualifiedName'),
'{id}', to_jsonb(gen_random_uuid())
)
FROM test_case tc
WHERE dqdts.entityfqnHash = tc.fqnHash;
-- Add id column to data_quality_data_time_series table
-- after we have added the id values to the records
ALTER TABLE data_quality_data_time_series
ADD COLUMN id VARCHAR(36) GENERATED ALWAYS AS (json ->> 'id') STORED,
ADD CONSTRAINT id_unique UNIQUE (id);
-- Create index on id column
CREATE INDEX IF NOT EXISTS data_quality_data_time_series_id_index ON data_quality_data_time_series (id);