diff --git a/bootstrap/sql/migrations/native/1.6.3/mysql/schemaChanges.sql b/bootstrap/sql/migrations/native/1.6.3/mysql/schemaChanges.sql new file mode 100644 index 000000000000..1bd78fc4dc8f --- /dev/null +++ b/bootstrap/sql/migrations/native/1.6.3/mysql/schemaChanges.sql @@ -0,0 +1,5 @@ +-- Add constraint to apps_data_store +ALTER TABLE apps_data_store ADD CONSTRAINT entity_relationship_pky PRIMARY KEY (identifier, type); +UPDATE user_entity SET json = JSON_SET(json, '$.isBot', false) WHERE JSON_EXTRACT(json, '$.isBot') IS NULL; +ALTER TABLE user_entity ADD COLUMN isBot BOOLEAN GENERATED ALWAYS AS (json -> '$.isBot') NOT NULL; +CREATE INDEX idx_isBot ON user_entity (isBot); \ No newline at end of file diff --git a/bootstrap/sql/migrations/native/1.6.3/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.6.3/postgres/schemaChanges.sql new file mode 100644 index 000000000000..b8a8f413fc01 --- /dev/null +++ b/bootstrap/sql/migrations/native/1.6.3/postgres/schemaChanges.sql @@ -0,0 +1,5 @@ +-- Add constraint to apps_data_store +ALTER TABLE apps_data_store ADD CONSTRAINT entity_relationship_pky PRIMARY KEY (identifier, type); +UPDATE user_entity SET json = jsonb_set(json::jsonb, '{isBot}', 'false'::jsonb, true) WHERE NOT (json ? 'isBot'); +ALTER TABLE user_entity ADD COLUMN isBot BOOLEAN GENERATED ALWAYS AS ((json ->> 'deleted')::boolean) STORED NOT NULL; +CREATE INDEX idx_isBot ON user_entity (isBot); \ No newline at end of file diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java index 86437cc72752..ca6fd40a9196 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java @@ -4830,11 +4830,11 @@ default String getTimeSeriesTableName() { interface AppsDataStore { @ConnectionAwareSqlUpdate( value = - "INSERT INTO apps_data_store(identifier, type, json) VALUES (:identifier, :type, :json)", + "INSERT INTO apps_data_store(identifier, type, json) VALUES (:identifier, :type, :json) ON DUPLICATE KEY UPDATE json = VALUES(json)", connectionType = MYSQL) @ConnectionAwareSqlUpdate( value = - "INSERT INTO apps_data_store(identifier, type, json) VALUES (:identifier, :type, :json :: jsonb)", + "INSERT INTO apps_data_store(identifier, type, json) VALUES (:identifier, :type, :json :: jsonb) ON CONFLICT (identifier, type) DO UPDATE SET json = EXCLUDED.json", connectionType = POSTGRES) void insert( @Bind("identifier") String identifier,