fix: fan out receipts and align tenant schema
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
-- Keep device push token schema aligned across tenant business databases.
|
||||
-- The current test environment uses:
|
||||
-- default -> tinode
|
||||
-- system -> meeting_im
|
||||
|
||||
SET @im_schema = 'tinode';
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN sdk_version VARCHAR(64) NOT NULL DEFAULT '''' AFTER platform'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'sdk_version'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN push_env VARCHAR(32) NOT NULL DEFAULT '''' AFTER sdk_version'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'push_env'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN notification_permission VARCHAR(32) NOT NULL DEFAULT '''' AFTER push_env'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'notification_permission'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_schema = 'meeting_im';
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN sdk_version VARCHAR(64) NOT NULL DEFAULT '''' AFTER platform'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'sdk_version'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN push_env VARCHAR(32) NOT NULL DEFAULT '''' AFTER sdk_version'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'push_env'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_device_push_tokens ADD COLUMN notification_permission VARCHAR(32) NOT NULL DEFAULT '''' AFTER push_env'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_device_push_tokens'
|
||||
AND column_name = 'notification_permission'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
@@ -1,14 +1,34 @@
|
||||
-- Add personal privacy switch for requiring approval when others invite the user into a group.
|
||||
-- Default is off to preserve existing behavior.
|
||||
-- Run this for every tenant business database. The current test environment uses:
|
||||
-- default -> tinode
|
||||
-- system -> meeting_im
|
||||
|
||||
SET @im_schema = 'tinode';
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
'ALTER TABLE tinode.im_user_privacy_settings ADD COLUMN group_invite_verification TINYINT NOT NULL DEFAULT 0 AFTER read_receipts',
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_user_privacy_settings ADD COLUMN group_invite_verification TINYINT NOT NULL DEFAULT 0 AFTER read_receipts'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'tinode'
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_user_privacy_settings'
|
||||
AND column_name = 'group_invite_verification'
|
||||
);
|
||||
PREPARE im_stmt FROM @im_sql;
|
||||
EXECUTE im_stmt;
|
||||
DEALLOCATE PREPARE im_stmt;
|
||||
|
||||
SET @im_schema = 'meeting_im';
|
||||
SET @im_sql = (
|
||||
SELECT IF(
|
||||
COUNT(*) = 0,
|
||||
CONCAT('ALTER TABLE ', @im_schema, '.im_user_privacy_settings ADD COLUMN group_invite_verification TINYINT NOT NULL DEFAULT 0 AFTER read_receipts'),
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @im_schema
|
||||
AND table_name = 'im_user_privacy_settings'
|
||||
AND column_name = 'group_invite_verification'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user