mirror of
https://github.com/hanzoai/team.git
synced 2026-11-01 07:55:31 +00:00
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
61 lines
2.0 KiB
SQL
61 lines
2.0 KiB
SQL
SET @preparedStatement = (SELECT IF(
|
|
(
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE table_name = 'ChannelMembers'
|
|
AND table_schema = DATABASE()
|
|
AND column_name = 'NotifyProps'
|
|
AND column_type != 'JSON'
|
|
) > 0,
|
|
'ALTER TABLE ChannelMembers MODIFY COLUMN NotifyProps JSON;',
|
|
'SELECT 1'
|
|
));
|
|
|
|
PREPARE alterIfExists FROM @preparedStatement;
|
|
EXECUTE alterIfExists;
|
|
DEALLOCATE PREPARE alterIfExists;
|
|
|
|
SET @preparedStatement = (SELECT IF(
|
|
(
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
|
WHERE table_name = 'ChannelMembers'
|
|
AND table_schema = DATABASE()
|
|
AND index_name = 'idx_channelmembers_user_id'
|
|
) > 0,
|
|
'DROP INDEX idx_channelmembers_user_id ON ChannelMembers;',
|
|
'SELECT 1'
|
|
));
|
|
|
|
PREPARE removeIndexIfExists FROM @preparedStatement;
|
|
EXECUTE removeIndexIfExists;
|
|
DEALLOCATE PREPARE removeIndexIfExists;
|
|
|
|
SET @preparedStatement = (SELECT IF(
|
|
(
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
|
WHERE table_name = 'ChannelMembers'
|
|
AND table_schema = DATABASE()
|
|
AND index_name = 'idx_channelmembers_user_id_channel_id_last_viewed_at'
|
|
) > 0,
|
|
'SELECT 1',
|
|
'CREATE INDEX idx_channelmembers_user_id_channel_id_last_viewed_at ON ChannelMembers(UserId, ChannelId, LastViewedAt);'
|
|
));
|
|
|
|
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
|
EXECUTE createIndexIfNotExists;
|
|
DEALLOCATE PREPARE createIndexIfNotExists;
|
|
|
|
SET @preparedStatement = (SELECT IF(
|
|
(
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
|
WHERE table_name = 'ChannelMembers'
|
|
AND table_schema = DATABASE()
|
|
AND index_name = 'idx_channelmembers_channel_id_scheme_guest_user_id'
|
|
) > 0,
|
|
'SELECT 1',
|
|
'CREATE INDEX idx_channelmembers_channel_id_scheme_guest_user_id ON ChannelMembers(ChannelId, SchemeGuest, UserId);'
|
|
));
|
|
|
|
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
|
EXECUTE createIndexIfNotExists;
|
|
DEALLOCATE PREPARE createIndexIfNotExists;
|