Add Onboarding SQL (#19525)

* Add Primary Key Migration

* Update queries and conflict on apps data store

* Update queries and conflict on apps data store

* add index on isBot
This commit is contained in:
Mohit Yadav 2025-01-28 11:45:58 +05:30 committed by GitHub
parent 5118bd6048
commit 58d5988a16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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);

View File

@ -4893,11 +4893,11 @@ public interface CollectionDAO {
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,