Mono repo -> Master (#22553)
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
Этот коммит содержится в:
13
server/channels/db/assets.go
Обычный файл
13
server/channels/db/assets.go
Обычный файл
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package db
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed migrations
|
||||
var assets embed.FS
|
||||
|
||||
func Assets() embed.FS {
|
||||
return assets
|
||||
}
|
||||
422
server/channels/db/migrations/migrations.list
Обычный файл
422
server/channels/db/migrations/migrations.list
Обычный файл
@@ -0,0 +1,422 @@
|
||||
# Autogenerated file to synchronize migrations sequence in the PR workflow, please do not edit.
|
||||
#
|
||||
channels/db/migrations/mysql/000001_create_teams.down.sql
|
||||
channels/db/migrations/mysql/000001_create_teams.up.sql
|
||||
channels/db/migrations/mysql/000002_create_team_members.down.sql
|
||||
channels/db/migrations/mysql/000002_create_team_members.up.sql
|
||||
channels/db/migrations/mysql/000003_create_cluster_discovery.down.sql
|
||||
channels/db/migrations/mysql/000003_create_cluster_discovery.up.sql
|
||||
channels/db/migrations/mysql/000004_create_command_webhooks.down.sql
|
||||
channels/db/migrations/mysql/000004_create_command_webhooks.up.sql
|
||||
channels/db/migrations/mysql/000005_create_compliances.down.sql
|
||||
channels/db/migrations/mysql/000005_create_compliances.up.sql
|
||||
channels/db/migrations/mysql/000006_create_emojis.down.sql
|
||||
channels/db/migrations/mysql/000006_create_emojis.up.sql
|
||||
channels/db/migrations/mysql/000007_create_user_groups.down.sql
|
||||
channels/db/migrations/mysql/000007_create_user_groups.up.sql
|
||||
channels/db/migrations/mysql/000008_create_group_members.down.sql
|
||||
channels/db/migrations/mysql/000008_create_group_members.up.sql
|
||||
channels/db/migrations/mysql/000009_create_group_teams.down.sql
|
||||
channels/db/migrations/mysql/000009_create_group_teams.up.sql
|
||||
channels/db/migrations/mysql/000010_create_group_channels.down.sql
|
||||
channels/db/migrations/mysql/000010_create_group_channels.up.sql
|
||||
channels/db/migrations/mysql/000011_create_link_metadata.down.sql
|
||||
channels/db/migrations/mysql/000011_create_link_metadata.up.sql
|
||||
channels/db/migrations/mysql/000012_create_commands.down.sql
|
||||
channels/db/migrations/mysql/000012_create_commands.up.sql
|
||||
channels/db/migrations/mysql/000013_create_incoming_webhooks.down.sql
|
||||
channels/db/migrations/mysql/000013_create_incoming_webhooks.up.sql
|
||||
channels/db/migrations/mysql/000014_create_outgoing_webhooks.down.sql
|
||||
channels/db/migrations/mysql/000014_create_outgoing_webhooks.up.sql
|
||||
channels/db/migrations/mysql/000015_create_systems.down.sql
|
||||
channels/db/migrations/mysql/000015_create_systems.up.sql
|
||||
channels/db/migrations/mysql/000016_create_reactions.down.sql
|
||||
channels/db/migrations/mysql/000016_create_reactions.up.sql
|
||||
channels/db/migrations/mysql/000017_create_roles.down.sql
|
||||
channels/db/migrations/mysql/000017_create_roles.up.sql
|
||||
channels/db/migrations/mysql/000018_create_schemes.down.sql
|
||||
channels/db/migrations/mysql/000018_create_schemes.up.sql
|
||||
channels/db/migrations/mysql/000019_create_licenses.down.sql
|
||||
channels/db/migrations/mysql/000019_create_licenses.up.sql
|
||||
channels/db/migrations/mysql/000020_create_posts.down.sql
|
||||
channels/db/migrations/mysql/000020_create_posts.up.sql
|
||||
channels/db/migrations/mysql/000021_create_product_notice_view_state.down.sql
|
||||
channels/db/migrations/mysql/000021_create_product_notice_view_state.up.sql
|
||||
channels/db/migrations/mysql/000022_create_sessions.down.sql
|
||||
channels/db/migrations/mysql/000022_create_sessions.up.sql
|
||||
channels/db/migrations/mysql/000023_create_terms_of_service.down.sql
|
||||
channels/db/migrations/mysql/000023_create_terms_of_service.up.sql
|
||||
channels/db/migrations/mysql/000024_create_audits.down.sql
|
||||
channels/db/migrations/mysql/000024_create_audits.up.sql
|
||||
channels/db/migrations/mysql/000025_create_oauth_access_data.down.sql
|
||||
channels/db/migrations/mysql/000025_create_oauth_access_data.up.sql
|
||||
channels/db/migrations/mysql/000026_create_preferences.down.sql
|
||||
channels/db/migrations/mysql/000026_create_preferences.up.sql
|
||||
channels/db/migrations/mysql/000027_create_status.down.sql
|
||||
channels/db/migrations/mysql/000027_create_status.up.sql
|
||||
channels/db/migrations/mysql/000028_create_tokens.down.sql
|
||||
channels/db/migrations/mysql/000028_create_tokens.up.sql
|
||||
channels/db/migrations/mysql/000029_create_bots.down.sql
|
||||
channels/db/migrations/mysql/000029_create_bots.up.sql
|
||||
channels/db/migrations/mysql/000030_create_user_access_tokens.down.sql
|
||||
channels/db/migrations/mysql/000030_create_user_access_tokens.up.sql
|
||||
channels/db/migrations/mysql/000031_create_remote_clusters.down.sql
|
||||
channels/db/migrations/mysql/000031_create_remote_clusters.up.sql
|
||||
channels/db/migrations/mysql/000032_create_sharedchannels.down.sql
|
||||
channels/db/migrations/mysql/000032_create_sharedchannels.up.sql
|
||||
channels/db/migrations/mysql/000033_create_sidebar_channels.down.sql
|
||||
channels/db/migrations/mysql/000033_create_sidebar_channels.up.sql
|
||||
channels/db/migrations/mysql/000034_create_oauthauthdata.down.sql
|
||||
channels/db/migrations/mysql/000034_create_oauthauthdata.up.sql
|
||||
channels/db/migrations/mysql/000035_create_sharedchannelattachments.down.sql
|
||||
channels/db/migrations/mysql/000035_create_sharedchannelattachments.up.sql
|
||||
channels/db/migrations/mysql/000036_create_sharedchannelusers.down.sql
|
||||
channels/db/migrations/mysql/000036_create_sharedchannelusers.up.sql
|
||||
channels/db/migrations/mysql/000037_create_sharedchannelremotes.down.sql
|
||||
channels/db/migrations/mysql/000037_create_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/mysql/000038_create_jobs.down.sql
|
||||
channels/db/migrations/mysql/000038_create_jobs.up.sql
|
||||
channels/db/migrations/mysql/000039_create_channel_member_history.down.sql
|
||||
channels/db/migrations/mysql/000039_create_channel_member_history.up.sql
|
||||
channels/db/migrations/mysql/000040_create_sidebar_categories.down.sql
|
||||
channels/db/migrations/mysql/000040_create_sidebar_categories.up.sql
|
||||
channels/db/migrations/mysql/000041_create_upload_sessions.down.sql
|
||||
channels/db/migrations/mysql/000041_create_upload_sessions.up.sql
|
||||
channels/db/migrations/mysql/000042_create_threads.down.sql
|
||||
channels/db/migrations/mysql/000042_create_threads.up.sql
|
||||
channels/db/migrations/mysql/000043_thread_memberships.down.sql
|
||||
channels/db/migrations/mysql/000043_thread_memberships.up.sql
|
||||
channels/db/migrations/mysql/000044_create_user_terms_of_service.down.sql
|
||||
channels/db/migrations/mysql/000044_create_user_terms_of_service.up.sql
|
||||
channels/db/migrations/mysql/000045_create_plugin_key_value_store.down.sql
|
||||
channels/db/migrations/mysql/000045_create_plugin_key_value_store.up.sql
|
||||
channels/db/migrations/mysql/000046_create_users.down.sql
|
||||
channels/db/migrations/mysql/000046_create_users.up.sql
|
||||
channels/db/migrations/mysql/000047_create_file_info.down.sql
|
||||
channels/db/migrations/mysql/000047_create_file_info.up.sql
|
||||
channels/db/migrations/mysql/000048_create_oauth_apps.down.sql
|
||||
channels/db/migrations/mysql/000048_create_oauth_apps.up.sql
|
||||
channels/db/migrations/mysql/000049_create_channels.down.sql
|
||||
channels/db/migrations/mysql/000049_create_channels.up.sql
|
||||
channels/db/migrations/mysql/000050_create_channelmembers.down.sql
|
||||
channels/db/migrations/mysql/000050_create_channelmembers.up.sql
|
||||
channels/db/migrations/mysql/000051_create_msg_root_count.down.sql
|
||||
channels/db/migrations/mysql/000051_create_msg_root_count.up.sql
|
||||
channels/db/migrations/mysql/000052_create_public_channels.down.sql
|
||||
channels/db/migrations/mysql/000052_create_public_channels.up.sql
|
||||
channels/db/migrations/mysql/000053_create_retention_policies.down.sql
|
||||
channels/db/migrations/mysql/000053_create_retention_policies.up.sql
|
||||
channels/db/migrations/mysql/000054_create_crt_channelmembership_count.down.sql
|
||||
channels/db/migrations/mysql/000054_create_crt_channelmembership_count.up.sql
|
||||
channels/db/migrations/mysql/000055_create_crt_thread_count_and_unreads.down.sql
|
||||
channels/db/migrations/mysql/000055_create_crt_thread_count_and_unreads.up.sql
|
||||
channels/db/migrations/mysql/000056_upgrade_channels_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000056_upgrade_channels_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000057_upgrade_command_webhooks_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000057_upgrade_command_webhooks_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000058_upgrade_channelmembers_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000058_upgrade_channelmembers_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000059_upgrade_users_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000059_upgrade_users_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000060_upgrade_jobs_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000060_upgrade_jobs_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000061_upgrade_link_metadata_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000061_upgrade_link_metadata_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000062_upgrade_sessions_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000062_upgrade_sessions_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000063_upgrade_threads_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000063_upgrade_threads_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000064_upgrade_status_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000064_upgrade_status_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000065_upgrade_groupchannels_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000065_upgrade_groupchannels_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000066_upgrade_posts_v6.0.down.sql
|
||||
channels/db/migrations/mysql/000066_upgrade_posts_v6.0.up.sql
|
||||
channels/db/migrations/mysql/000067_upgrade_channelmembers_v6.1.down.sql
|
||||
channels/db/migrations/mysql/000067_upgrade_channelmembers_v6.1.up.sql
|
||||
channels/db/migrations/mysql/000068_upgrade_teammembers_v6.1.down.sql
|
||||
channels/db/migrations/mysql/000068_upgrade_teammembers_v6.1.up.sql
|
||||
channels/db/migrations/mysql/000069_upgrade_jobs_v6.1.down.sql
|
||||
channels/db/migrations/mysql/000069_upgrade_jobs_v6.1.up.sql
|
||||
channels/db/migrations/mysql/000070_upgrade_cte_v6.1.down.sql
|
||||
channels/db/migrations/mysql/000070_upgrade_cte_v6.1.up.sql
|
||||
channels/db/migrations/mysql/000071_upgrade_sessions_v6.1.down.sql
|
||||
channels/db/migrations/mysql/000071_upgrade_sessions_v6.1.up.sql
|
||||
channels/db/migrations/mysql/000072_upgrade_schemes_v6.3.down.sql
|
||||
channels/db/migrations/mysql/000072_upgrade_schemes_v6.3.up.sql
|
||||
channels/db/migrations/mysql/000073_upgrade_plugin_key_value_store_v6.3.down.sql
|
||||
channels/db/migrations/mysql/000073_upgrade_plugin_key_value_store_v6.3.up.sql
|
||||
channels/db/migrations/mysql/000074_upgrade_users_v6.3.down.sql
|
||||
channels/db/migrations/mysql/000074_upgrade_users_v6.3.up.sql
|
||||
channels/db/migrations/mysql/000075_alter_upload_sessions_index.down.sql
|
||||
channels/db/migrations/mysql/000075_alter_upload_sessions_index.up.sql
|
||||
channels/db/migrations/mysql/000076_upgrade_lastrootpostat.down.sql
|
||||
channels/db/migrations/mysql/000076_upgrade_lastrootpostat.up.sql
|
||||
channels/db/migrations/mysql/000077_upgrade_users_v6.5.down.sql
|
||||
channels/db/migrations/mysql/000077_upgrade_users_v6.5.up.sql
|
||||
channels/db/migrations/mysql/000078_create_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/mysql/000078_create_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/mysql/000079_usergroups_displayname_index.down.sql
|
||||
channels/db/migrations/mysql/000079_usergroups_displayname_index.up.sql
|
||||
channels/db/migrations/mysql/000080_posts_createat_id.down.sql
|
||||
channels/db/migrations/mysql/000080_posts_createat_id.up.sql
|
||||
channels/db/migrations/mysql/000081_threads_deleteat.down.sql
|
||||
channels/db/migrations/mysql/000081_threads_deleteat.up.sql
|
||||
channels/db/migrations/mysql/000082_upgrade_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/mysql/000082_upgrade_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/mysql/000083_threads_threaddeleteat.down.sql
|
||||
channels/db/migrations/mysql/000083_threads_threaddeleteat.up.sql
|
||||
channels/db/migrations/mysql/000084_recent_searches.down.sql
|
||||
channels/db/migrations/mysql/000084_recent_searches.up.sql
|
||||
channels/db/migrations/mysql/000085_fileinfo_add_archived_column.down.sql
|
||||
channels/db/migrations/mysql/000085_fileinfo_add_archived_column.up.sql
|
||||
channels/db/migrations/mysql/000086_add_cloud_limits_archived.down.sql
|
||||
channels/db/migrations/mysql/000086_add_cloud_limits_archived.up.sql
|
||||
channels/db/migrations/mysql/000087_sidebar_categories_index.down.sql
|
||||
channels/db/migrations/mysql/000087_sidebar_categories_index.up.sql
|
||||
channels/db/migrations/mysql/000088_remaining_migrations.down.sql
|
||||
channels/db/migrations/mysql/000088_remaining_migrations.up.sql
|
||||
channels/db/migrations/mysql/000089_add-channelid-to-reaction.down.sql
|
||||
channels/db/migrations/mysql/000089_add-channelid-to-reaction.up.sql
|
||||
channels/db/migrations/mysql/000090_create_enums.down.sql
|
||||
channels/db/migrations/mysql/000090_create_enums.up.sql
|
||||
channels/db/migrations/mysql/000091_create_post_reminder.down.sql
|
||||
channels/db/migrations/mysql/000091_create_post_reminder.up.sql
|
||||
channels/db/migrations/mysql/000092_add_createat_to_teammembers.down.sql
|
||||
channels/db/migrations/mysql/000092_add_createat_to_teammembers.up.sql
|
||||
channels/db/migrations/mysql/000093_notify_admin.down.sql
|
||||
channels/db/migrations/mysql/000093_notify_admin.up.sql
|
||||
channels/db/migrations/mysql/000094_threads_teamid.down.sql
|
||||
channels/db/migrations/mysql/000094_threads_teamid.up.sql
|
||||
channels/db/migrations/mysql/000095_remove_posts_parentid.down.sql
|
||||
channels/db/migrations/mysql/000095_remove_posts_parentid.up.sql
|
||||
channels/db/migrations/mysql/000096_threads_threadteamid.down.sql
|
||||
channels/db/migrations/mysql/000096_threads_threadteamid.up.sql
|
||||
channels/db/migrations/mysql/000097_create_posts_priority.down.sql
|
||||
channels/db/migrations/mysql/000097_create_posts_priority.up.sql
|
||||
channels/db/migrations/mysql/000098_create_post_acknowledgements.down.sql
|
||||
channels/db/migrations/mysql/000098_create_post_acknowledgements.up.sql
|
||||
channels/db/migrations/mysql/000099_create_drafts.down.sql
|
||||
channels/db/migrations/mysql/000099_create_drafts.up.sql
|
||||
channels/db/migrations/mysql/000100_add_draft_priority_column.down.sql
|
||||
channels/db/migrations/mysql/000100_add_draft_priority_column.up.sql
|
||||
channels/db/migrations/mysql/000101_create_true_up_review_history.down.sql
|
||||
channels/db/migrations/mysql/000101_create_true_up_review_history.up.sql
|
||||
channels/db/migrations/mysql/000102_posts_originalid_index.down.sql
|
||||
channels/db/migrations/mysql/000102_posts_originalid_index.up.sql
|
||||
channels/db/migrations/mysql/000103_add_sentat_to_notifyadmin.down.sql
|
||||
channels/db/migrations/mysql/000103_add_sentat_to_notifyadmin.up.sql
|
||||
channels/db/migrations/mysql/000104_upgrade_notifyadmin.down.sql
|
||||
channels/db/migrations/mysql/000104_upgrade_notifyadmin.up.sql
|
||||
channels/db/migrations/mysql/000105_remove_tokens.down.sql
|
||||
channels/db/migrations/mysql/000105_remove_tokens.up.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.down.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.up.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.up.sql
|
||||
channels/db/migrations/postgres/000003_create_cluster_discovery.down.sql
|
||||
channels/db/migrations/postgres/000003_create_cluster_discovery.up.sql
|
||||
channels/db/migrations/postgres/000004_create_command_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000004_create_command_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000005_create_compliances.down.sql
|
||||
channels/db/migrations/postgres/000005_create_compliances.up.sql
|
||||
channels/db/migrations/postgres/000006_create_emojis.down.sql
|
||||
channels/db/migrations/postgres/000006_create_emojis.up.sql
|
||||
channels/db/migrations/postgres/000007_create_user_groups.down.sql
|
||||
channels/db/migrations/postgres/000007_create_user_groups.up.sql
|
||||
channels/db/migrations/postgres/000008_create_group_members.down.sql
|
||||
channels/db/migrations/postgres/000008_create_group_members.up.sql
|
||||
channels/db/migrations/postgres/000009_create_group_teams.down.sql
|
||||
channels/db/migrations/postgres/000009_create_group_teams.up.sql
|
||||
channels/db/migrations/postgres/000010_create_group_channels.down.sql
|
||||
channels/db/migrations/postgres/000010_create_group_channels.up.sql
|
||||
channels/db/migrations/postgres/000011_create_link_metadata.down.sql
|
||||
channels/db/migrations/postgres/000011_create_link_metadata.up.sql
|
||||
channels/db/migrations/postgres/000012_create_commands.down.sql
|
||||
channels/db/migrations/postgres/000012_create_commands.up.sql
|
||||
channels/db/migrations/postgres/000013_create_incoming_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000013_create_incoming_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000014_create_outgoing_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000014_create_outgoing_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000015_create_systems.down.sql
|
||||
channels/db/migrations/postgres/000015_create_systems.up.sql
|
||||
channels/db/migrations/postgres/000016_create_reactions.down.sql
|
||||
channels/db/migrations/postgres/000016_create_reactions.up.sql
|
||||
channels/db/migrations/postgres/000017_create_roles.down.sql
|
||||
channels/db/migrations/postgres/000017_create_roles.up.sql
|
||||
channels/db/migrations/postgres/000018_create_schemes.down.sql
|
||||
channels/db/migrations/postgres/000018_create_schemes.up.sql
|
||||
channels/db/migrations/postgres/000019_create_licenses.down.sql
|
||||
channels/db/migrations/postgres/000019_create_licenses.up.sql
|
||||
channels/db/migrations/postgres/000020_create_posts.down.sql
|
||||
channels/db/migrations/postgres/000020_create_posts.up.sql
|
||||
channels/db/migrations/postgres/000021_create_product_notice_view_state.down.sql
|
||||
channels/db/migrations/postgres/000021_create_product_notice_view_state.up.sql
|
||||
channels/db/migrations/postgres/000022_create_sessions.down.sql
|
||||
channels/db/migrations/postgres/000022_create_sessions.up.sql
|
||||
channels/db/migrations/postgres/000023_create_terms_of_service.down.sql
|
||||
channels/db/migrations/postgres/000023_create_terms_of_service.up.sql
|
||||
channels/db/migrations/postgres/000024_create_audits.down.sql
|
||||
channels/db/migrations/postgres/000024_create_audits.up.sql
|
||||
channels/db/migrations/postgres/000025_create_oauth_access_data.down.sql
|
||||
channels/db/migrations/postgres/000025_create_oauth_access_data.up.sql
|
||||
channels/db/migrations/postgres/000026_create_preferences.down.sql
|
||||
channels/db/migrations/postgres/000026_create_preferences.up.sql
|
||||
channels/db/migrations/postgres/000027_create_status.down.sql
|
||||
channels/db/migrations/postgres/000027_create_status.up.sql
|
||||
channels/db/migrations/postgres/000028_create_tokens.down.sql
|
||||
channels/db/migrations/postgres/000028_create_tokens.up.sql
|
||||
channels/db/migrations/postgres/000029_create_bots.down.sql
|
||||
channels/db/migrations/postgres/000029_create_bots.up.sql
|
||||
channels/db/migrations/postgres/000030_create_user_access_tokens.down.sql
|
||||
channels/db/migrations/postgres/000030_create_user_access_tokens.up.sql
|
||||
channels/db/migrations/postgres/000031_create_remote_clusters.down.sql
|
||||
channels/db/migrations/postgres/000031_create_remote_clusters.up.sql
|
||||
channels/db/migrations/postgres/000032_create_sharedchannels.down.sql
|
||||
channels/db/migrations/postgres/000032_create_sharedchannels.up.sql
|
||||
channels/db/migrations/postgres/000033_create_sidebar_channels.down.sql
|
||||
channels/db/migrations/postgres/000033_create_sidebar_channels.up.sql
|
||||
channels/db/migrations/postgres/000034_create_oauthauthdata.down.sql
|
||||
channels/db/migrations/postgres/000034_create_oauthauthdata.up.sql
|
||||
channels/db/migrations/postgres/000035_create_sharedchannelattachments.down.sql
|
||||
channels/db/migrations/postgres/000035_create_sharedchannelattachments.up.sql
|
||||
channels/db/migrations/postgres/000036_create_sharedchannelusers.down.sql
|
||||
channels/db/migrations/postgres/000036_create_sharedchannelusers.up.sql
|
||||
channels/db/migrations/postgres/000037_create_sharedchannelremotes.down.sql
|
||||
channels/db/migrations/postgres/000037_create_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/postgres/000038_create_jobs.down.sql
|
||||
channels/db/migrations/postgres/000038_create_jobs.up.sql
|
||||
channels/db/migrations/postgres/000039_create_channel_member_history.down.sql
|
||||
channels/db/migrations/postgres/000039_create_channel_member_history.up.sql
|
||||
channels/db/migrations/postgres/000040_create_sidebar_categories.down.sql
|
||||
channels/db/migrations/postgres/000040_create_sidebar_categories.up.sql
|
||||
channels/db/migrations/postgres/000041_create_upload_sessions.down.sql
|
||||
channels/db/migrations/postgres/000041_create_upload_sessions.up.sql
|
||||
channels/db/migrations/postgres/000042_create_threads.down.sql
|
||||
channels/db/migrations/postgres/000042_create_threads.up.sql
|
||||
channels/db/migrations/postgres/000043_thread_memberships.down.sql
|
||||
channels/db/migrations/postgres/000043_thread_memberships.up.sql
|
||||
channels/db/migrations/postgres/000044_create_user_terms_of_service.down.sql
|
||||
channels/db/migrations/postgres/000044_create_user_terms_of_service.up.sql
|
||||
channels/db/migrations/postgres/000045_create_plugin_key_value_store.down.sql
|
||||
channels/db/migrations/postgres/000045_create_plugin_key_value_store.up.sql
|
||||
channels/db/migrations/postgres/000046_create_users.down.sql
|
||||
channels/db/migrations/postgres/000046_create_users.up.sql
|
||||
channels/db/migrations/postgres/000047_create_file_info.down.sql
|
||||
channels/db/migrations/postgres/000047_create_file_info.up.sql
|
||||
channels/db/migrations/postgres/000048_create_oauth_apps.down.sql
|
||||
channels/db/migrations/postgres/000048_create_oauth_apps.up.sql
|
||||
channels/db/migrations/postgres/000049_create_channels.down.sql
|
||||
channels/db/migrations/postgres/000049_create_channels.up.sql
|
||||
channels/db/migrations/postgres/000050_create_channelmembers.down.sql
|
||||
channels/db/migrations/postgres/000050_create_channelmembers.up.sql
|
||||
channels/db/migrations/postgres/000051_create_msg_root_count.down.sql
|
||||
channels/db/migrations/postgres/000051_create_msg_root_count.up.sql
|
||||
channels/db/migrations/postgres/000052_create_public_channels.down.sql
|
||||
channels/db/migrations/postgres/000052_create_public_channels.up.sql
|
||||
channels/db/migrations/postgres/000053_create_retention_policies.down.sql
|
||||
channels/db/migrations/postgres/000053_create_retention_policies.up.sql
|
||||
channels/db/migrations/postgres/000054_create_crt_channelmembership_count.down.sql
|
||||
channels/db/migrations/postgres/000054_create_crt_channelmembership_count.up.sql
|
||||
channels/db/migrations/postgres/000055_create_crt_thread_count_and_unreads.down.sql
|
||||
channels/db/migrations/postgres/000055_create_crt_thread_count_and_unreads.up.sql
|
||||
channels/db/migrations/postgres/000056_upgrade_channels_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000056_upgrade_channels_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000057_upgrade_command_webhooks_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000057_upgrade_command_webhooks_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000058_upgrade_channelmembers_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000058_upgrade_channelmembers_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000059_upgrade_users_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000059_upgrade_users_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000060_upgrade_jobs_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000060_upgrade_jobs_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000061_upgrade_link_metadata_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000061_upgrade_link_metadata_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000062_upgrade_sessions_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000062_upgrade_sessions_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000063_upgrade_threads_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000063_upgrade_threads_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000064_upgrade_status_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000064_upgrade_status_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000065_upgrade_groupchannels_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000065_upgrade_groupchannels_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000066_upgrade_posts_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000066_upgrade_posts_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000067_upgrade_channelmembers_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000067_upgrade_channelmembers_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000068_upgrade_teammembers_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000068_upgrade_teammembers_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000069_upgrade_jobs_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000069_upgrade_jobs_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000070_upgrade_cte_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000070_upgrade_cte_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000071_upgrade_sessions_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000071_upgrade_sessions_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000072_upgrade_schemes_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000072_upgrade_schemes_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000073_upgrade_plugin_key_value_store_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000073_upgrade_plugin_key_value_store_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000074_upgrade_users_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000074_upgrade_users_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000075_alter_upload_sessions_index.down.sql
|
||||
channels/db/migrations/postgres/000075_alter_upload_sessions_index.up.sql
|
||||
channels/db/migrations/postgres/000076_upgrade_lastrootpostat.down.sql
|
||||
channels/db/migrations/postgres/000076_upgrade_lastrootpostat.up.sql
|
||||
channels/db/migrations/postgres/000077_upgrade_users_v6.5.down.sql
|
||||
channels/db/migrations/postgres/000077_upgrade_users_v6.5.up.sql
|
||||
channels/db/migrations/postgres/000078_create_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/postgres/000078_create_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/postgres/000079_usergroups_displayname_index.down.sql
|
||||
channels/db/migrations/postgres/000079_usergroups_displayname_index.up.sql
|
||||
channels/db/migrations/postgres/000080_posts_createat_id.down.sql
|
||||
channels/db/migrations/postgres/000080_posts_createat_id.up.sql
|
||||
channels/db/migrations/postgres/000081_threads_deleteat.down.sql
|
||||
channels/db/migrations/postgres/000081_threads_deleteat.up.sql
|
||||
channels/db/migrations/postgres/000082_upgrade_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/postgres/000082_upgrade_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/postgres/000083_threads_threaddeleteat.down.sql
|
||||
channels/db/migrations/postgres/000083_threads_threaddeleteat.up.sql
|
||||
channels/db/migrations/postgres/000084_recent_searches.down.sql
|
||||
channels/db/migrations/postgres/000084_recent_searches.up.sql
|
||||
channels/db/migrations/postgres/000085_fileinfo_add_archived_column.down.sql
|
||||
channels/db/migrations/postgres/000085_fileinfo_add_archived_column.up.sql
|
||||
channels/db/migrations/postgres/000086_add_cloud_limits_archived.down.sql
|
||||
channels/db/migrations/postgres/000086_add_cloud_limits_archived.up.sql
|
||||
channels/db/migrations/postgres/000087_sidebar_categories_index.down.sql
|
||||
channels/db/migrations/postgres/000087_sidebar_categories_index.up.sql
|
||||
channels/db/migrations/postgres/000088_remaining_migrations.down.sql
|
||||
channels/db/migrations/postgres/000088_remaining_migrations.up.sql
|
||||
channels/db/migrations/postgres/000089_add-channelid-to-reaction.down.sql
|
||||
channels/db/migrations/postgres/000089_add-channelid-to-reaction.up.sql
|
||||
channels/db/migrations/postgres/000090_create_enums.down.sql
|
||||
channels/db/migrations/postgres/000090_create_enums.up.sql
|
||||
channels/db/migrations/postgres/000091_create_post_reminder.down.sql
|
||||
channels/db/migrations/postgres/000091_create_post_reminder.up.sql
|
||||
channels/db/migrations/postgres/000092_add_createat_to_teamembers.down.sql
|
||||
channels/db/migrations/postgres/000092_add_createat_to_teamembers.up.sql
|
||||
channels/db/migrations/postgres/000093_notify_admin.down.sql
|
||||
channels/db/migrations/postgres/000093_notify_admin.up.sql
|
||||
channels/db/migrations/postgres/000094_threads_teamid.down.sql
|
||||
channels/db/migrations/postgres/000094_threads_teamid.up.sql
|
||||
channels/db/migrations/postgres/000095_remove_posts_parentid.down.sql
|
||||
channels/db/migrations/postgres/000095_remove_posts_parentid.up.sql
|
||||
channels/db/migrations/postgres/000096_threads_threadteamid.down.sql
|
||||
channels/db/migrations/postgres/000096_threads_threadteamid.up.sql
|
||||
channels/db/migrations/postgres/000097_create_posts_priority.down.sql
|
||||
channels/db/migrations/postgres/000097_create_posts_priority.up.sql
|
||||
channels/db/migrations/postgres/000098_create_post_acknowledgements.down.sql
|
||||
channels/db/migrations/postgres/000098_create_post_acknowledgements.up.sql
|
||||
channels/db/migrations/postgres/000099_create_drafts.down.sql
|
||||
channels/db/migrations/postgres/000099_create_drafts.up.sql
|
||||
channels/db/migrations/postgres/000100_add_draft_priority_column.down.sql
|
||||
channels/db/migrations/postgres/000100_add_draft_priority_column.up.sql
|
||||
channels/db/migrations/postgres/000101_create_true_up_review_history.down.sql
|
||||
channels/db/migrations/postgres/000101_create_true_up_review_history.up.sql
|
||||
channels/db/migrations/postgres/000102_posts_originalid_index.down.sql
|
||||
channels/db/migrations/postgres/000102_posts_originalid_index.up.sql
|
||||
channels/db/migrations/postgres/000103_add_sentat_to_notifyadmin.down.sql
|
||||
channels/db/migrations/postgres/000103_add_sentat_to_notifyadmin.up.sql
|
||||
channels/db/migrations/postgres/000104_upgrade_notifyadmin.down.sql
|
||||
channels/db/migrations/postgres/000104_upgrade_notifyadmin.up.sql
|
||||
channels/db/migrations/postgres/000105_remove_tokens.down.sql
|
||||
channels/db/migrations/postgres/000105_remove_tokens.up.sql
|
||||
76
server/channels/db/migrations/mysql/000001_create_teams.down.sql
Обычный файл
76
server/channels/db/migrations/mysql/000001_create_teams.down.sql
Обычный файл
@@ -0,0 +1,76 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_teams_name'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_teams_name ON Teams(Name);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AllowOpenInvite'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams DROP COLUMN AllowOpenInvite;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastTeamIconUpdate'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams DROP COLUMN LastTeamIconUpdate;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams DROP COLUMN Description;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams DROP COLUMN GroupConstrained;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS Teams;
|
||||
177
server/channels/db/migrations/mysql/000001_create_teams.up.sql
Обычный файл
177
server/channels/db/migrations/mysql/000001_create_teams.up.sql
Обычный файл
@@ -0,0 +1,177 @@
|
||||
CREATE TABLE IF NOT EXISTS Teams (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
DisplayName varchar(64) DEFAULT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
Description varchar(255) DEFAULT NULL,
|
||||
Email varchar(128) DEFAULT NULL,
|
||||
Type varchar(255) DEFAULT NULL,
|
||||
CompanyName varchar(64) DEFAULT NULL,
|
||||
AllowedDomains text,
|
||||
InviteId varchar(32) DEFAULT NULL,
|
||||
SchemeId varchar(26) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Name (Name),
|
||||
KEY idx_teams_invite_id (InviteId),
|
||||
KEY idx_teams_update_at (UpdateAt),
|
||||
KEY idx_teams_create_at (CreateAt),
|
||||
KEY idx_teams_delete_at (DeleteAt),
|
||||
KEY idx_teams_scheme_id (SchemeId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AllowOpenInvite'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Teams ADD AllowOpenInvite bool;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastTeamIconUpdate'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Teams ADD LastTeamIconUpdate bigint;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Teams ADD Description varchar(255);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Teams ADD GroupConstrained tinyint(1);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_teams_name'
|
||||
) > 0,
|
||||
'DROP INDEX idx_teams_name ON Teams;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AllowedDomains'
|
||||
AND column_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams MODIFY COLUMN AllowedDomains text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
AND column_type != 'tinyint(1)'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams MODIFY COLUMN GroupConstrained tinyint(1);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_teams_scheme_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_teams_scheme_id ON Teams(SchemeId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Type'
|
||||
AND column_type != 'varchar(255)'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams MODIFY COLUMN Type varchar(255);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Teams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeId'
|
||||
AND column_type != 'varchar(26)'
|
||||
) > 0,
|
||||
'ALTER TABLE Teams MODIFY COLUMN SchemeId varchar(26);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1,76 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_teammembers_team_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_teammembers_team_id ON TeamMembers(TeamId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeUser'
|
||||
) > 0,
|
||||
'ALTER TABLE TeamMembers DROP COLUMN SchemeUser;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeAdmin'
|
||||
) > 0,
|
||||
'ALTER TABLE TeamMembers DROP COLUMN SchemeAdmin;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeGuest'
|
||||
) > 0,
|
||||
'ALTER TABLE TeamMembers DROP COLUMN SchemeGuest;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DeleteAt'
|
||||
) > 0,
|
||||
'ALTER TABLE TeamMembers DROP COLUMN DeleteAt;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS TeamMembers;
|
||||
@@ -0,0 +1,85 @@
|
||||
CREATE TABLE IF NOT EXISTS TeamMembers (
|
||||
TeamId varchar(26) NOT NULL,
|
||||
UserId varchar(26) NOT NULL,
|
||||
Roles varchar(64),
|
||||
DeleteAt bigint(20),
|
||||
PRIMARY KEY (TeamId, UserId),
|
||||
KEY idx_teammembers_user_id (UserId),
|
||||
KEY idx_teammembers_delete_at (DeleteAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeUser'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE TeamMembers ADD SchemeUser tinyint(4);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeAdmin'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE TeamMembers ADD SchemeAdmin tinyint(4);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeGuest'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE TeamMembers ADD SchemeGuest tinyint(4);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DeleteAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE TeamMembers ADD DeleteAt bigint(20);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'TeamMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_teammembers_team_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_teammembers_team_id ON TeamMembers;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS ClusterDiscovery;
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS ClusterDiscovery (
|
||||
Id varchar(26) NOT NULL,
|
||||
Type varchar(64) DEFAULT NULL,
|
||||
ClusterName varchar(64) DEFAULT NULL,
|
||||
Hostname text,
|
||||
GossipPort int(11) DEFAULT NULL,
|
||||
Port integer DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
LastPingAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS CommandWebhooks;
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS CommandWebhooks (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
CommandId varchar(26) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
ChannelId varchar(26) DEFAULT NULL,
|
||||
RootId varchar(26) DEFAULT NULL,
|
||||
ParentId varchar(26) DEFAULT NULL,
|
||||
UseCount integer DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
KEY idx_command_webhook_create_at (CreateAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Compliances;
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS Compliances (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20),
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
Status varchar(64) DEFAULT NULL,
|
||||
Count integer DEFAULT NULL,
|
||||
`Desc` text,
|
||||
Type varchar(64) DEFAULT NULL,
|
||||
StartAt bigint(20),
|
||||
EndAt bigint(20),
|
||||
Keywords text,
|
||||
Emails text,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Emoji'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_emoji_name'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_emoji_name ON Emoji(Name);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS Emoji;
|
||||
73
server/channels/db/migrations/mysql/000006_create_emojis.up.sql
Обычный файл
73
server/channels/db/migrations/mysql/000006_create_emojis.up.sql
Обычный файл
@@ -0,0 +1,73 @@
|
||||
CREATE TABLE IF NOT EXISTS Emoji (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY (Name, DeleteAt),
|
||||
KEY idx_emoji_update_at (UpdateAt),
|
||||
KEY idx_emoji_create_at (CreateAt),
|
||||
KEY idx_emoji_delete_at (DeleteAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'Emoji'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_emoji_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX ON Emoji(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'Emoji'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_emoji_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX ON Emoji(DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'Emoji'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_emoji_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX ON Emoji(UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Emoji'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_emoji_name'
|
||||
) > 0,
|
||||
'DROP INDEX idx_emoji_name ON Emoji;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS UserGroups;
|
||||
@@ -0,0 +1,62 @@
|
||||
CREATE TABLE IF NOT EXISTS UserGroups (
|
||||
Id varchar(26) NOT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
DisplayName varchar(128) DEFAULT NULL,
|
||||
Description text,
|
||||
Source varchar(64) DEFAULT NULL,
|
||||
RemoteId varchar(48) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
AllowReference tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Name (Name),
|
||||
UNIQUE KEY Source (Source, RemoteId),
|
||||
KEY idx_usergroups_remote_id (RemoteId),
|
||||
KEY idx_usergroups_delete_at (DeleteAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UserGroups'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AllowReference'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE UserGroups ADD AllowReference tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserGroups'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_usergroups_remote_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_usergroups_remote_id ON UserGroups(RemoteId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserGroups'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_usergroups_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_usergroups_delete_at ON UserGroups(DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS GroupMembers;
|
||||
@@ -0,0 +1,23 @@
|
||||
CREATE TABLE IF NOT EXISTS GroupMembers (
|
||||
GroupId varchar(26) NOT NULL,
|
||||
UserId varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (GroupId, UserId),
|
||||
KEY idx_groupmembers_create_at (CreateAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'GroupMembers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_groupmembers_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_groupmembers_create_at ON GroupMembers(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS GroupTeams;
|
||||
@@ -0,0 +1,55 @@
|
||||
CREATE TABLE IF NOT EXISTS GroupTeams (
|
||||
GroupId varchar(26) NOT NULL,
|
||||
AutoAdd tinyint(1),
|
||||
SchemeAdmin tinyint(1) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
TeamId varchar(26) NOT NULL,
|
||||
PRIMARY KEY (GroupId, TeamId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'GroupTeams'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeAdmin'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE GroupTeams ADD COLUMN SchemeAdmin tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'GroupTeams'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_groupteams_schemeadmin'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_groupteams_schemeadmin ON GroupTeams(SchemeAdmin);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'GroupTeams'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_groupteams_teamid'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_groupteams_teamid ON GroupTeams(TeamId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS GroupChannels;
|
||||
@@ -0,0 +1,57 @@
|
||||
CREATE TABLE IF NOT EXISTS GroupChannels (
|
||||
GroupId varchar(26) NOT NULL,
|
||||
AutoAdd tinyint(1),
|
||||
SchemeAdmin tinyint(1) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
ChannelId varchar(26) NOT NULL,
|
||||
PRIMARY KEY (GroupId, ChannelId),
|
||||
KEY idx_groupchannels_schemeadmin (SchemeAdmin),
|
||||
KEY idx_groupchannels_channelid (ChannelId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'GroupChannels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_groupchannels_channelid'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_groupchannels_channelid ON GroupChannels (ChannelId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'GroupChannels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_groupchannels_schemeadmin'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_groupchannels_schemeadmin ON GroupChannels(SchemeAdmin);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'GroupChannels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeAdmin'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE GroupChannels ADD COLUMN SchemeAdmin tinyint(1);'
|
||||
));
|
||||
|
||||
PREPARE createColumnIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createColumnIfNotExists;
|
||||
DEALLOCATE PREPARE createColumnIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS LinkMetadata;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS LinkMetadata (
|
||||
Hash bigint(20) NOT NULL,
|
||||
URL text,
|
||||
Timestamp bigint(20) DEFAULT NULL,
|
||||
Type varchar(16) DEFAULT NULL,
|
||||
Data text,
|
||||
PRIMARY KEY (Hash),
|
||||
KEY idx_link_metadata_url_timestamp (URL(512),Timestamp)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Commands'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'PluginId'
|
||||
) > 0,
|
||||
'ALTER TABLE Commands DROP COLUMN PluginId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS Commands;
|
||||
@@ -0,0 +1,65 @@
|
||||
CREATE TABLE IF NOT EXISTS Commands (
|
||||
Id varchar(26) NOT NULL,
|
||||
Token varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
TeamId varchar(26) DEFAULT NULL,
|
||||
`Trigger` varchar(128) DEFAULT NULL,
|
||||
Method varchar(1) DEFAULT NULL,
|
||||
Username varchar(64) DEFAULT NULL,
|
||||
IconURL text,
|
||||
AutoComplete tinyint(1) DEFAULT NULL,
|
||||
AutoCompleteDesc text,
|
||||
AutoCompleteHint text,
|
||||
DisplayName varchar(64) DEFAULT NULL,
|
||||
Description varchar(128) DEFAULT NULL,
|
||||
URL text,
|
||||
PRIMARY KEY (Id),
|
||||
KEY idx_command_team_id (TeamId),
|
||||
KEY idx_command_update_at (UpdateAt),
|
||||
KEY idx_command_create_at (CreateAt),
|
||||
KEY idx_command_delete_at (DeleteAt)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Commands'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'PluginId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Commands ADD PluginId varchar(190);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_5280 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
DECLARE
|
||||
SYSTEMS_TABLE_EXISTS INT;
|
||||
SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
TABLE_NAME = 'Systems'
|
||||
AND table_schema = DATABASE() INTO SYSTEMS_TABLE_EXISTS;
|
||||
IF (SYSTEMS_TABLE_EXISTS > 0) THEN
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('5.28.0')) THEN
|
||||
UPDATE Commands SET PluginId = '' WHERE PluginId IS NULL;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_5280 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_5280;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS IncomingWebhooks;
|
||||
@@ -0,0 +1,192 @@
|
||||
CREATE TABLE IF NOT EXISTS IncomingWebhooks (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
ChannelId varchar(26) DEFAULT NULL,
|
||||
TeamId varchar(26) DEFAULT NULL,
|
||||
DisplayName varchar(64) DEFAULT NULL,
|
||||
Description varchar(128) DEFAULT NULL,
|
||||
Username varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY(Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Username'
|
||||
) > 0,
|
||||
'ALTER TABLE IncomingWebhooks MODIFY Username VARCHAR(255);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IconURL'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE IncomingWebhooks ADD IconURL text;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ChannelLocked'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE IncomingWebhooks ADD ChannelLocked tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
) > 0,
|
||||
'ALTER TABLE IncomingWebhooks MODIFY Description TEXT;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_incoming_webhook_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_incoming_webhook_user_id ON IncomingWebhooks (UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_incoming_webhook_team_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_incoming_webhook_team_id ON IncomingWebhooks (TeamId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_incoming_webhook_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_incoming_webhook_update_at ON IncomingWebhooks (UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_incoming_webhook_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_incoming_webhook_create_at ON IncomingWebhooks (CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_incoming_webhook_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_incoming_webhook_delete_at ON IncomingWebhooks (DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
CREATE PROCEDURE CheckColumnMaxLength(
|
||||
in columnName varchar(45),
|
||||
in threshold int )
|
||||
BEGIN
|
||||
DECLARE C INT;
|
||||
|
||||
SELECT COALESCE(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN CHAR_LENGTH(columnName) > threshold THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
),
|
||||
0) INTO C
|
||||
FROM IncomingWebhooks;
|
||||
|
||||
IF(C > 0) THEN
|
||||
SET @messageText = CONCAT('IncomingWebhooks column ', columnName, ' has data larger that ', threshold, ' characters');
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = @messageText;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
CALL CheckColumnMaxLength('Username', 255);
|
||||
CALL CheckColumnMaxLength('IconURL', 1024);
|
||||
|
||||
DROP PROCEDURE IF EXISTS CheckColumnMaxLength;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'IncomingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
AND column_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE IncomingWebhooks MODIFY COLUMN Description text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS OutgoingWebhooks;
|
||||
@@ -0,0 +1,197 @@
|
||||
CREATE TABLE IF NOT EXISTS OutgoingWebhooks (
|
||||
Id varchar(26) NOT NULL,
|
||||
Token varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
ChannelId varchar(26) DEFAULT NULL,
|
||||
TeamId varchar(26) DEFAULT NULL,
|
||||
TriggerWords text,
|
||||
CallbackURLs text,
|
||||
DisplayName varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY(Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ContentType'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OutgoingWebhooks ADD ContentType VARCHAR(128);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'TriggerWhen'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OutgoingWebhooks ADD TriggerWhen int(11) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Username'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OutgoingWebhooks ADD Username VARCHAR(64) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IconURL'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OutgoingWebhooks ADD IconURL text;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OutgoingWebhooks ADD Description text;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_outgoing_webhook_team_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_outgoing_webhook_team_id ON OutgoingWebhooks (TeamId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_outgoing_webhook_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_outgoing_webhook_update_at ON OutgoingWebhooks (UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_outgoing_webhook_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_outgoing_webhook_create_at ON OutgoingWebhooks (CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_outgoing_webhook_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_outgoing_webhook_delete_at ON OutgoingWebhooks (DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Description'
|
||||
AND column_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE OutgoingWebhooks MODIFY COLUMN Description text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IconURL'
|
||||
AND column_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE OutgoingWebhooks MODIFY COLUMN IconURL text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT Column_Default FROM Information_Schema.Columns
|
||||
WHERE table_name = 'OutgoingWebhooks'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Username'
|
||||
) IS NULL,
|
||||
'ALTER TABLE OutgoingWebhooks ALTER COLUMN Username SET DEFAULT NULL;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfDefaultNull FROM @preparedStatement;
|
||||
EXECUTE alterIfDefaultNull;
|
||||
DEALLOCATE PREPARE alterIfDefaultNull;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Systems;
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS Systems (
|
||||
Name VARCHAR(64) NOT NULL,
|
||||
Value text,
|
||||
PRIMARY KEY (Name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Reactions;
|
||||
@@ -0,0 +1,76 @@
|
||||
CREATE TABLE IF NOT EXISTS Reactions (
|
||||
UserId varchar(26) NOT NULL,
|
||||
PostId varchar(26) NOT NULL,
|
||||
EmojiName varchar(64) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Reactions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'UpdateAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Reactions ADD COLUMN UpdateAt bigint(20);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Reactions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DeleteAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Reactions ADD COLUMN DeleteAt bigint(20);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
CREATE PROCEDURE AlterPrimaryKey()
|
||||
BEGIN
|
||||
DECLARE existingPK varchar(26) default '';
|
||||
|
||||
SELECT IFNULL(GROUP_CONCAT(column_name ORDER BY seq_in_index), '') INTO existingPK
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Reactions'
|
||||
AND index_name = 'PRIMARY'
|
||||
GROUP BY index_name;
|
||||
|
||||
IF existingPK != 'PostId,UserId,EmojiName' THEN
|
||||
IF existingPk != '' THEN
|
||||
ALTER TABLE Reactions DROP PRIMARY KEY;
|
||||
END IF;
|
||||
|
||||
ALTER TABLE Reactions ADD PRIMARY KEY (PostId, UserID, EmojiName);
|
||||
END IF;
|
||||
END;
|
||||
|
||||
CALL AlterPrimaryKey();
|
||||
|
||||
DROP PROCEDURE IF EXISTS AlterPrimaryKey;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Reactions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Reactions ADD COLUMN RemoteId varchar(26);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Roles;
|
||||
61
server/channels/db/migrations/mysql/000017_create_roles.up.sql
Обычный файл
61
server/channels/db/migrations/mysql/000017_create_roles.up.sql
Обычный файл
@@ -0,0 +1,61 @@
|
||||
CREATE TABLE IF NOT EXISTS Roles (
|
||||
Id varchar(26) NOT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
DisplayName varchar(128) DEFAULT NULL,
|
||||
Description text,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
Permissions text,
|
||||
SchemeManaged tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Name (Name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'BuiltIn'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Roles ADD BuiltIn tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_500 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('5.0.0')) THEN
|
||||
UPDATE Roles SET SchemeManaged = 0
|
||||
WHERE Name NOT IN ('system_user', 'system_admin', 'team_user', 'team_admin', 'channel_user', 'channel_admin');
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_500 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_500;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Permissions'
|
||||
) > 0,
|
||||
'ALTER TABLE Roles MODIFY Permissions longtext;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Schemes;
|
||||
121
server/channels/db/migrations/mysql/000018_create_schemes.up.sql
Обычный файл
121
server/channels/db/migrations/mysql/000018_create_schemes.up.sql
Обычный файл
@@ -0,0 +1,121 @@
|
||||
CREATE TABLE IF NOT EXISTS Schemes (
|
||||
Id varchar(26) NOT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
DisplayName varchar(128) DEFAULT NULL,
|
||||
Description text,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
Scope varchar(32) DEFAULT NULL,
|
||||
DefaultTeamAdminRole varchar(64) DEFAULT NULL,
|
||||
DefaultTeamUserRole varchar(64) DEFAULT NULL,
|
||||
DefaultChannelAdminRole varchar(64) DEFAULT NULL,
|
||||
DefaultChannelUserRole varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Name (Name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DefaultTeamGuestRole'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Schemes ADD DefaultTeamGuestRole varchar(64);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DefaultChannelGuestRole'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Schemes ADD DefaultChannelGuestRole varchar(64);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DefaultTeamGuestRole'
|
||||
) > 0,
|
||||
'ALTER TABLE Schemes MODIFY DefaultTeamGuestRole varchar(64);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DefaultChannelGuestRole'
|
||||
) > 0,
|
||||
'ALTER TABLE Schemes MODIFY DefaultChannelGuestRole varchar(64);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_schemes_channel_guest_role'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_schemes_channel_guest_role ON Schemes(DefaultChannelGuestRole);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_schemes_channel_user_role'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_schemes_channel_user_role ON Schemes(DefaultChannelUserRole);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Schemes'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_schemes_channel_admin_role'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_schemes_channel_admin_role ON Schemes(DefaultChannelAdminRole);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Licenses;
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS Licenses (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
Bytes text,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
16
server/channels/db/migrations/mysql/000020_create_posts.down.sql
Обычный файл
16
server/channels/db/migrations/mysql/000020_create_posts.down.sql
Обычный файл
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_channel_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_channel_id ON Posts(ChannelId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS Posts;
|
||||
257
server/channels/db/migrations/mysql/000020_create_posts.up.sql
Обычный файл
257
server/channels/db/migrations/mysql/000020_create_posts.up.sql
Обычный файл
@@ -0,0 +1,257 @@
|
||||
CREATE TABLE IF NOT EXISTS Posts (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
ChannelId varchar(26) DEFAULT NULL,
|
||||
RootId varchar(26) DEFAULT NULL,
|
||||
ParentId varchar(26) DEFAULT NULL,
|
||||
OriginalId varchar(26) DEFAULT NULL,
|
||||
Message text,
|
||||
Type varchar(26) DEFAULT NULL,
|
||||
Props text,
|
||||
Hashtags text,
|
||||
Filenames text,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'FileIds'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Posts ADD FileIds text;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'HasReactions'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Posts ADD HasReactions tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'EditAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Posts ADD EditAt bigint(20) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IsPinned'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Posts ADD IsPinned tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_update_at ON Posts (UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_create_at ON Posts(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_delete_at ON Posts(DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_root_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_root_id ON Posts(RootId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_user_id ON Posts(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_is_pinned'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_is_pinned ON Posts(IsPinned);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_channel_id_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_channel_id_update_at ON Posts(ChannelId, UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_channel_id_delete_at_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_posts_channel_id_delete_at_create_at ON Posts(ChannelId, DeleteAt, CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_message_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_posts_message_txt ON Posts(Message);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_hashtags_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_posts_hashtags_txt ON Posts(Hashtags);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Posts ADD RemoteId varchar(26);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Posts'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_posts_channel_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_posts_channel_id ON Posts;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_user_notice'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_notice_views_user_notice ON ProductNoticeViewState(UserId, NoticeId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_notice_views_user_id ON ProductNoticeViewState(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS ProductNoticeViewState;
|
||||
@@ -0,0 +1,67 @@
|
||||
CREATE TABLE IF NOT EXISTS ProductNoticeViewState (
|
||||
UserId VARCHAR(26) NOT NULL,
|
||||
NoticeId VARCHAR(26) NOT NULL,
|
||||
Viewed int(11),
|
||||
Timestamp bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (UserId, NoticeId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_timestamp'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_notice_views_timestamp ON ProductNoticeViewState (Timestamp);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_notice_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_notice_views_notice_id ON ProductNoticeViewState (NoticeId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_notice_views_user_id ON ProductNoticeViewState;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ProductNoticeViewState'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_notice_views_user_notice'
|
||||
) > 0,
|
||||
'DROP INDEX idx_notice_views_user_notice ON ProductNoticeViewState;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Sessions;
|
||||
116
server/channels/db/migrations/mysql/000022_create_sessions.up.sql
Обычный файл
116
server/channels/db/migrations/mysql/000022_create_sessions.up.sql
Обычный файл
@@ -0,0 +1,116 @@
|
||||
CREATE TABLE IF NOT EXISTS Sessions (
|
||||
Id varchar(26) PRIMARY KEY,
|
||||
Token varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
ExpiresAt bigint(20) DEFAULT NULL,
|
||||
LastActivityAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
DeviceId text,
|
||||
Roles varchar(64) DEFAULT NULL,
|
||||
IsOAuth tinyint(1),
|
||||
Props text
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpiredNotify'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Sessions ADD ExpiredNotify tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sessions_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sessions_user_id ON Sessions(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sessions_token'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sessions_token ON Sessions(Token);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sessions_expires_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sessions_expires_at ON Sessions(ExpiresAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sessions_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sessions_create_at ON Sessions(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Sessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sessions_last_activity_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sessions_last_activity_at ON Sessions(LastActivityAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_5120 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('5.12.0')) THEN
|
||||
DELETE FROM Sessions where ExpiresAt > 3000000000000;
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_5120 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_5120;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS TermsOfService;
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS TermsOfService (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
Text text,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Audits;
|
||||
25
server/channels/db/migrations/mysql/000024_create_audits.up.sql
Обычный файл
25
server/channels/db/migrations/mysql/000024_create_audits.up.sql
Обычный файл
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE IF NOT EXISTS Audits (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
Action text,
|
||||
ExtraInfo text,
|
||||
IpAddress varchar(64) DEFAULT NULL,
|
||||
SessionId varchar(26) DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Audits'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_audits_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_audits_user_id ON Audits(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthaccessdata_client_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_oauthaccessdata_client_id ON OAuthAccessData(ClientId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS OAuthAccessData;
|
||||
@@ -0,0 +1,159 @@
|
||||
CREATE TABLE IF NOT EXISTS OAuthAccessData (
|
||||
Token varchar(26) NOT NULL,
|
||||
RefreshToken varchar(26) DEFAULT NULL,
|
||||
RedirectUri text,
|
||||
ClientId varchar(26) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
PRIMARY KEY (Token),
|
||||
UNIQUE KEY (ClientId, UserId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ClientId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthAccessData ADD ClientId varchar(26) DEFAULT "";'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'UserId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthAccessData ADD UserId varchar(26) DEFAULT "";'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthaccessdata_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_oauthaccessdata_user_id ON OAuthAccessData(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpiresAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthAccessData ADD ExpiresAt bigint(20) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthaccessdata_auth_code'
|
||||
) > 0,
|
||||
'DROP INDEX idx_oauthaccessdata_auth_code ON OAuthAccessData;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AuthCode'
|
||||
) > 0,
|
||||
'ALTER TABLE OAuthAccessData DROP COLUMN AuthCode;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Scope'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthAccessData ADD Scope varchar(128) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'ClientId_2'
|
||||
) > 0,
|
||||
'DROP INDEX ClientId_2 ON OAuthAccessData;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.statistics
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthaccessdata_refresh_token'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_oauthaccessdata_refresh_token ON OAuthAccessData(RefreshToken);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthAccessData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthaccessdata_client_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_oauthaccessdata_client_id ON OAuthAccessData;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Preferences'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_preferences_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_preferences_user_id ON Preferences(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS Preferences;
|
||||
106
server/channels/db/migrations/mysql/000026_create_preferences.up.sql
Обычный файл
106
server/channels/db/migrations/mysql/000026_create_preferences.up.sql
Обычный файл
@@ -0,0 +1,106 @@
|
||||
CREATE TABLE IF NOT EXISTS Preferences (
|
||||
UserId varchar(26) NOT NULL,
|
||||
Category varchar(32) NOT NULL,
|
||||
Name varchar(32) NOT NULL,
|
||||
Value text,
|
||||
PRIMARY KEY (UserId, Category, Name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Preferences'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Value'
|
||||
AND data_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE Preferences MODIFY Value text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Preferences'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_preferences_category'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_preferences_category ON Preferences(Category);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Preferences'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_preferences_name'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_preferences_name ON Preferences(Name);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
CREATE PROCEDURE RenameSolarizedThemeWithUnderscore()
|
||||
BEGIN
|
||||
DECLARE finished INTEGER DEFAULT 0;
|
||||
DECLARE curUserId VARCHAR(26);
|
||||
DECLARE curName VARCHAR(32);
|
||||
DECLARE curValue text;
|
||||
|
||||
DECLARE preference
|
||||
CURSOR FOR
|
||||
SELECT UserId, Name, Value
|
||||
FROM Preferences
|
||||
WHERE Category = 'theme' AND Value LIKE '%solarized_%';
|
||||
|
||||
-- declare NOT FOUND handler
|
||||
DECLARE CONTINUE HANDLER
|
||||
FOR NOT FOUND SET finished = 1;
|
||||
|
||||
OPEN preference;
|
||||
|
||||
getPreference: LOOP
|
||||
FETCH preference INTO curUserId, curName, curValue;
|
||||
IF finished = 1 THEN
|
||||
LEAVE getPreference;
|
||||
END IF;
|
||||
|
||||
-- update affected rows
|
||||
UPDATE Preferences
|
||||
SET Value = replace(curValue, 'solaraized_', 'solarized-')
|
||||
WHERE Category = 'theme'
|
||||
AND UserId = curUserId
|
||||
AND Name = curName;
|
||||
END LOOP getPreference;
|
||||
END;
|
||||
|
||||
CALL RenameSolarizedThemeWithUnderscore();
|
||||
|
||||
DROP PROCEDURE IF EXISTS RenameSolarizedThemeWithUnderscore;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Preferences'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_preferences_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_preferences_user_id ON Preferences;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_status_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_status_user_id ON Status(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS Status;
|
||||
83
server/channels/db/migrations/mysql/000027_create_status.up.sql
Обычный файл
83
server/channels/db/migrations/mysql/000027_create_status.up.sql
Обычный файл
@@ -0,0 +1,83 @@
|
||||
CREATE TABLE IF NOT EXISTS Status (
|
||||
UserId varchar(26) NOT NULL,
|
||||
Status varchar(32) DEFAULT NULL,
|
||||
Manual tinyint(1) DEFAULT NULL,
|
||||
LastActivityAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (UserId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ActiveChannel'
|
||||
) > 0,
|
||||
'ALTER TABLE Status DROP COLUMN ActiveChannel;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_status_status'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_status_status ON Status(Status);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DNDEndTime'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Status ADD COLUMN DNDEndTime BIGINT;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'PrevStatus'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Status ADD COLUMN PrevStatus VARCHAR(32);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Status'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_status_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_status_user_id ON Status;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Tokens;
|
||||
23
server/channels/db/migrations/mysql/000028_create_tokens.up.sql
Обычный файл
23
server/channels/db/migrations/mysql/000028_create_tokens.up.sql
Обычный файл
@@ -0,0 +1,23 @@
|
||||
CREATE TABLE IF NOT EXISTS Tokens (
|
||||
Token varchar(64) NOT NULL,
|
||||
CreateAt bigint(20),
|
||||
Type varchar(64) DEFAULT NULL,
|
||||
Extra text,
|
||||
PRIMARY KEY (Token)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Tokens'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Extra'
|
||||
AND data_type != 'text'
|
||||
) > 0,
|
||||
'ALTER TABLE Tokens MODIFY Extra text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
16
server/channels/db/migrations/mysql/000029_create_bots.down.sql
Обычный файл
16
server/channels/db/migrations/mysql/000029_create_bots.down.sql
Обычный файл
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Bots'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastIconUpdate'
|
||||
) > 0,
|
||||
'ALTER TABLE Bots DROP COLUMN LastIconUpdate;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS bots;
|
||||
24
server/channels/db/migrations/mysql/000029_create_bots.up.sql
Обычный файл
24
server/channels/db/migrations/mysql/000029_create_bots.up.sql
Обычный файл
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE IF NOT EXISTS Bots (
|
||||
UserId varchar(26) NOT NULL,
|
||||
Description text,
|
||||
OwnerId varchar(190) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (UserId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Bots'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastIconUpdate'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Bots ADD LastIconUpdate bigint;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserAccessTokens'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_user_access_tokens_token'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_user_access_tokens_token ON UserAccessTokens(Token);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS UserAccessTokens;
|
||||
@@ -0,0 +1,53 @@
|
||||
CREATE TABLE IF NOT EXISTS UserAccessTokens (
|
||||
Id varchar(26) NOT NULL,
|
||||
Token varchar(26) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
Description text,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE (Token)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UserAccessTokens'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IsActive'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE UserAccessTokens ADD COLUMN IsActive tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterNotIfExists FROM @preparedStatement;
|
||||
EXECUTE alterNotIfExists;
|
||||
DEALLOCATE PREPARE alterNotIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserAccessTokens'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_user_access_tokens_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_user_access_tokens_user_id ON UserAccessTokens(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserAccessTokens'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_user_access_tokens_token'
|
||||
) > 0,
|
||||
'DROP INDEX idx_user_access_tokens_token ON UserAccessTokens;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS RemoteClusters;
|
||||
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE IF NOT EXISTS RemoteClusters (
|
||||
RemoteId VARCHAR(26) NOT NULL,
|
||||
RemoteTeamId VARCHAR(26),
|
||||
Name VARCHAR(64) NOT NULL,
|
||||
DisplayName VARCHAR(64),
|
||||
SiteURL text,
|
||||
CreateAt bigint,
|
||||
LastPingAt bigint,
|
||||
Token VARCHAR(26) DEFAULT NULL,
|
||||
RemoteToken VARCHAR(26),
|
||||
Topics text,
|
||||
CreatorId VARCHAR(26) DEFAULT NULL,
|
||||
PRIMARY KEY (RemoteId, Name)
|
||||
);
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'RemoteClusters'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'remote_clusters_site_url_unique'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE UNIQUE INDEX remote_clusters_site_url_unique ON RemoteClusters (RemoteTeamId, SiteURL (168));'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS SharedChannels;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS SharedChannels (
|
||||
ChannelId varchar(26) NOT NULL,
|
||||
TeamId varchar(26) DEFAULT NULL,
|
||||
Home tinyint(1) DEFAULT NULL,
|
||||
ReadOnly tinyint(1) DEFAULT NULL,
|
||||
ShareName varchar(64) DEFAULT NULL,
|
||||
ShareDisplayName varchar(64) DEFAULT NULL,
|
||||
SharePurpose varchar(250) DEFAULT NULL,
|
||||
ShareHeader text,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
RemoteId varchar(26) DEFAULT NULL,
|
||||
PRIMARY KEY (ChannelId),
|
||||
UNIQUE KEY ShareName (ShareName, TeamId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,17 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarChannels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'CategoryId'
|
||||
AND column_type != 'varchar(26)'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarChannels MODIFY CategoryId varchar(26);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS SidebarChannels;
|
||||
@@ -0,0 +1,23 @@
|
||||
CREATE TABLE IF NOT EXISTS SidebarChannels (
|
||||
ChannelId varchar(26) NOT NULL,
|
||||
UserId varchar(26) NOT NULL,
|
||||
CategoryId varchar(26) NOT NULL,
|
||||
SortOrder bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (ChannelId, UserId, CategoryId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarChannels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'CategoryId'
|
||||
AND column_type != 'varchar(128)'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarChannels MODIFY CategoryId varchar(128);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthAuthData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthauthdata_client_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_oauthauthdata_client_id ON OAuthAuthData(Code);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS OAuthAuthData;
|
||||
@@ -0,0 +1,38 @@
|
||||
CREATE TABLE IF NOT EXISTS OAuthAuthData (
|
||||
ClientId varchar(26) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
Code varchar(128) NOT NULL,
|
||||
ExpiresIn int(11) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
RedirectUri text,
|
||||
State text,
|
||||
Scope varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (Code)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthAuthData'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'State'
|
||||
AND (data_type != 'varchar' OR character_maximum_length != 1024)
|
||||
) > 0,
|
||||
'ALTER TABLE OAuthAuthData MODIFY State text;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthAuthData'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthauthdata_client_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_oauthauthdata_client_id ON OAuthAuthData;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS SharedChannelAttachments;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS SharedChannelAttachments (
|
||||
Id varchar(26) NOT NULL,
|
||||
FileId varchar(26) DEFAULT NULL,
|
||||
RemoteId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
LastSyncAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY FileId (FileId,RemoteId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sharedchannelusers_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sharedchannelusers_user_id ON SharedChannelUsers(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ChannelId'
|
||||
) > 0,
|
||||
'ALTER TABLE SharedChannelUsers DROP COLUMN ChannelId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS SharedChannelUsers;
|
||||
@@ -0,0 +1,68 @@
|
||||
CREATE TABLE IF NOT EXISTS SharedChannelUsers (
|
||||
Id varchar(26) NOT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
RemoteId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
LastSyncAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ChannelId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SharedChannelUsers ADD ChannelId varchar(26) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND constraint_type = 'UNIQUE'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SharedChannelUsers ADD CONSTRAINT UNIQUE KEY UserId(UserId, ChannelId, RemoteId)'
|
||||
));
|
||||
|
||||
PREPARE alterIfUniqueNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfUniqueNotExists;
|
||||
DEALLOCATE PREPARE alterIfUniqueNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sharedchannelusers_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_sharedchannelusers_user_id ON SharedChannelUsers;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'SharedChannelUsers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_sharedchannelusers_remote_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_sharedchannelusers_remote_id ON SharedChannelUsers(RemoteId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelRemotes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastPostId'
|
||||
) > 0,
|
||||
'ALTER TABLE SharedChannelRemotes DROP COLUMN LastPostId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelRemotes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastPostUpdateAt'
|
||||
) > 0,
|
||||
'ALTER TABLE SharedChannelRemotes DROP COLUMN LastPostUpdateAt;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS SharedChannelRemotes;
|
||||
@@ -0,0 +1,42 @@
|
||||
CREATE TABLE IF NOT EXISTS SharedChannelRemotes (
|
||||
Id varchar(26) NOT NULL,
|
||||
ChannelId varchar(26) NOT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
IsInviteAccepted tinyint(1) DEFAULT NULL,
|
||||
IsInviteConfirmed tinyint(1) DEFAULT NULL,
|
||||
RemoteId varchar(26) DEFAULT NULL,
|
||||
PRIMARY KEY (Id, ChannelId),
|
||||
UNIQUE KEY ChannelId (ChannelId, RemoteId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelRemotes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastPostUpdateAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SharedChannelRemotes ADD LastPostUpdateAt bigint;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelRemotes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastPostId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SharedChannelRemotes ADD LastPostId VARCHAR(26);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS Jobs;
|
||||
13
server/channels/db/migrations/mysql/000038_create_jobs.up.sql
Обычный файл
13
server/channels/db/migrations/mysql/000038_create_jobs.up.sql
Обычный файл
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE IF NOT EXISTS Jobs (
|
||||
Id varchar(26) NOT NULL,
|
||||
Type varchar(32) DEFAULT NULL,
|
||||
Priority bigint(20) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
StartAt bigint(20) DEFAULT NULL,
|
||||
LastActivityAt bigint(20) DEFAULT NULL,
|
||||
Status varchar(32) DEFAULT NULL,
|
||||
Progress bigint(20) DEFAULT NULL,
|
||||
Data text,
|
||||
PRIMARY KEY (Id),
|
||||
KEY idx_jobs_type (Type)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS ChannelMemberHistory;
|
||||
@@ -0,0 +1,37 @@
|
||||
CREATE TABLE IF NOT EXISTS ChannelMemberHistory (
|
||||
ChannelId varchar(26) NOT NULL,
|
||||
UserId varchar(26) NOT NULL,
|
||||
JoinTime bigint(20) NOT NULL,
|
||||
LeaveTime bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (ChannelId, UserId, JoinTime)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'ChannelMemberHistory'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Email'
|
||||
) > 0,
|
||||
'ALTER TABLE ChannelMemberHistory DROP COLUMN Email',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'ChannelMemberHistory'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Username'
|
||||
) > 0,
|
||||
'ALTER TABLE ChannelMemberHistory DROP COLUMN Username',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
@@ -0,0 +1,47 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Collapsed'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarCategories DROP COLUMN Collapsed;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Muted'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarCategories DROP COLUMN Muted;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Id'
|
||||
AND column_type != 'varchar(26)'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarCategories MODIFY Id varchar(26);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS SidebarCategories;
|
||||
@@ -0,0 +1,56 @@
|
||||
CREATE TABLE IF NOT EXISTS SidebarCategories (
|
||||
Id varchar(26) NOT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
TeamId varchar(26) DEFAULT NULL,
|
||||
SortOrder bigint(20) DEFAULT NULL,
|
||||
Sorting varchar(64) DEFAULT NULL,
|
||||
Type varchar(64) DEFAULT NULL,
|
||||
DisplayName varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Id'
|
||||
AND column_type != 'varchar(128)'
|
||||
) > 0,
|
||||
'ALTER TABLE SidebarCategories MODIFY Id varchar(128);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Muted'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SidebarCategories ADD COLUMN Muted tinyint(1);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SidebarCategories'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Collapsed'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SidebarCategories ADD COLUMN Collapsed tinyint(1);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'ALTER TABLE UploadSessions DROP RemoteId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ReqFileId'
|
||||
) > 0,
|
||||
'ALTER TABLE UploadSessions DROP ReqFileId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS UploadSessions;
|
||||
@@ -0,0 +1,104 @@
|
||||
CREATE TABLE IF NOT EXISTS UploadSessions (
|
||||
Id varchar(26) NOT NULL,
|
||||
Type varchar(32) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UserId varchar(26) DEFAULT NULL,
|
||||
ChannelId varchar(26) DEFAULT NULL,
|
||||
Filename text,
|
||||
Path text,
|
||||
FileSize bigint(20) DEFAULT NULL,
|
||||
FileOffset bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
);
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_uploadsessions_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_uploadsessions_user_id ON UploadSessions(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_uploadsessions_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_uploadsessions_create_at ON UploadSessions(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_uploadsessions_type'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_uploadsessions_type ON UploadSessions(Type);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE UploadSessions ADD RemoteId varchar(26) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'UploadSessions'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ReqFileId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE UploadSessions ADD ReqFileId varchar(26) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_5350 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('5.35.0')) THEN
|
||||
UPDATE UploadSessions SET RemoteId='', ReqFileId='' WHERE RemoteId IS NULL;
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_5350 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_5350;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Threads'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_threads_channel_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_threads_channel_id ON Threads;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Threads'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ChannelId'
|
||||
) > 0,
|
||||
'ALTER TABLE Threads DROP COLUMN ChannelId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS Threads;
|
||||
60
server/channels/db/migrations/mysql/000042_create_threads.up.sql
Обычный файл
60
server/channels/db/migrations/mysql/000042_create_threads.up.sql
Обычный файл
@@ -0,0 +1,60 @@
|
||||
CREATE TABLE IF NOT EXISTS Threads (
|
||||
PostId varchar(26) NOT NULL,
|
||||
ReplyCount bigint(20),
|
||||
LastReplyAt bigint(20),
|
||||
Participants text,
|
||||
PRIMARY KEY (PostId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Threads'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ChannelId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Threads ADD COLUMN ChannelId VARCHAR(26) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Threads'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_threads_channel_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_threads_channel_id ON Threads(ChannelId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_Empty_Threads ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
EMPTY_THREADS_EXIST INT;
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
Threads
|
||||
WHERE
|
||||
ChannelId IS NULL INTO EMPTY_THREADS_EXIST;
|
||||
IF(EMPTY_THREADS_EXIST > 0) THEN
|
||||
UPDATE
|
||||
Threads
|
||||
INNER JOIN Posts ON Posts.Id = Threads.PostId
|
||||
SET
|
||||
Threads.ChannelId = Posts.ChannelId
|
||||
WHERE
|
||||
Threads.ChannelId IS NULL;
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_Empty_Threads ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_Empty_Threads;
|
||||
@@ -0,0 +1,62 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_thread_memberships_user_id ON ThreadMemberships;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_last_view_at'
|
||||
) > 0,
|
||||
'DROP INDEX idx_thread_memberships_last_view_at ON ThreadMemberships;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_last_update_at'
|
||||
) > 0,
|
||||
'DROP INDEX idx_thread_memberships_last_update_at ON ThreadMemberships;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'UnreadMentions'
|
||||
) > 0,
|
||||
'ALTER TABLE ThreadMemberships DROP COLUMN UnreadMentions;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS ThreadMemberships;
|
||||
@@ -0,0 +1,68 @@
|
||||
CREATE TABLE IF NOT EXISTS ThreadMemberships (
|
||||
PostId varchar(26) NOT NULL,
|
||||
UserId varchar(26) NOT NULL,
|
||||
Following tinyint(1),
|
||||
LastViewed bigint(20) DEFAULT NULL,
|
||||
LastUpdated bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (PostId, UserId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'UnreadMentions'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE ThreadMemberships ADD UnreadMentions bigint(20) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_last_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_thread_memberships_last_update_at ON ThreadMemberships(LastUpdated);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_last_view_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_thread_memberships_last_view_at ON ThreadMemberships(LastViewed);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'ThreadMemberships'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_thread_memberships_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_thread_memberships_user_id ON ThreadMemberships(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1,16 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserTermsOfService'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_user_terms_of_service_user_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_user_terms_of_service_user_id ON UserTermsOfService(UserId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS UserTermsOfService;
|
||||
@@ -0,0 +1,43 @@
|
||||
CREATE TABLE IF NOT EXISTS UserTermsOfService (
|
||||
UserId varchar(26) NOT NULL,
|
||||
TermsOfServiceId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (UserId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE PROCEDURE MigrateToUserTermsOfServiceTable()
|
||||
BEGIN
|
||||
DECLARE COL_EXIST INT;
|
||||
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'AcceptedTermsOfServiceId' INTO COL_EXIST;
|
||||
|
||||
IF(COL_EXIST > 0) THEN
|
||||
INSERT INTO UserTermsOfService
|
||||
SELECT Id, AcceptedTermsOfServiceId as TermsOfServiceId, ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000)
|
||||
FROM Users
|
||||
WHERE AcceptedTermsOfServiceId != ''
|
||||
AND AcceptedTermsOfServiceId IS NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
CALL MigrateToUserTermsOfServiceTable();
|
||||
|
||||
DROP PROCEDURE IF EXISTS MigrateToUserTermsOfServiceTable;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'UserTermsOfService'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_user_terms_of_service_user_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_user_terms_of_service_user_id ON UserTermsOfService;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT Column_Default FROM Information_Schema.Columns
|
||||
WHERE table_name = 'PluginKeyValueStore'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpireAt'
|
||||
) IS NULL,
|
||||
'ALTER TABLE PluginKeyValueStore ALTER COLUMN ExpireAt SET DEFAULT 0;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfDefaultNull FROM @preparedStatement;
|
||||
EXECUTE alterIfDefaultNull;
|
||||
DEALLOCATE PREPARE alterIfDefaultNull;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'PluginKeyValueStore'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpireAt'
|
||||
) > 0,
|
||||
'ALTER TABLE PluginKeyValueStore DROP COLUMN ExpireAt;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS PluginKeyValueStore;
|
||||
@@ -0,0 +1,36 @@
|
||||
CREATE TABLE IF NOT EXISTS PluginKeyValueStore (
|
||||
PluginId varchar(190) NOT NULL,
|
||||
PKey varchar(50) NOT NULL,
|
||||
PValue mediumblob,
|
||||
PRIMARY KEY (PluginId, PKey)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'PluginKeyValueStore'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpireAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE PluginKeyValueStore ADD ExpireAt bigint(20) DEFAULT 0;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT Column_Default FROM Information_Schema.Columns
|
||||
WHERE table_name = 'PluginKeyValueStore'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ExpireAt'
|
||||
) = 0,
|
||||
'ALTER TABLE PluginKeyValueStore ALTER COLUMN ExpireAt SET DEFAULT NULL;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfDefaultZero FROM @preparedStatement;
|
||||
EXECUTE alterIfDefaultZero;
|
||||
DEALLOCATE PREPARE alterIfDefaultZero;
|
||||
31
server/channels/db/migrations/mysql/000046_create_users.down.sql
Обычный файл
31
server/channels/db/migrations/mysql/000046_create_users.down.sql
Обычный файл
@@ -0,0 +1,31 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_email'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_users_email ON Users(Email);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'ALTER TABLE Users DROP RemoteId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
DROP TABLE IF EXISTS Users;
|
||||
286
server/channels/db/migrations/mysql/000046_create_users.up.sql
Обычный файл
286
server/channels/db/migrations/mysql/000046_create_users.up.sql
Обычный файл
@@ -0,0 +1,286 @@
|
||||
CREATE TABLE IF NOT EXISTS Users (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
Username varchar(64) DEFAULT NULL,
|
||||
Password varchar(128) DEFAULT NULL,
|
||||
AuthData varchar(128) DEFAULT NULL,
|
||||
AuthService varchar(32) DEFAULT NULL,
|
||||
Email varchar(128) DEFAULT NULL,
|
||||
EmailVerified tinyint(1),
|
||||
Nickname varchar(64) DEFAULT NULL,
|
||||
FirstName varchar(64) DEFAULT NULL,
|
||||
LastName varchar(64) DEFAULT NULL,
|
||||
Roles varchar(256) DEFAULT NULL,
|
||||
AllowMarketing tinyint(1),
|
||||
Props text,
|
||||
NotifyProps text,
|
||||
LastPasswordUpdate bigint(20) DEFAULT NULL,
|
||||
LastPictureUpdate bigint(20) DEFAULT NULL,
|
||||
FailedAttempts integer,
|
||||
Locale varchar(5) DEFAULT NULL,
|
||||
MfaActive tinyint(1),
|
||||
MfaSecret varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Username (Username),
|
||||
UNIQUE KEY AuthData (AuthData),
|
||||
UNIQUE KEY Email (Email)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastActivityAt'
|
||||
) > 0,
|
||||
'ALTER TABLE Users DROP COLUMN LastActivityAt;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'LastPingAt'
|
||||
) > 0,
|
||||
'ALTER TABLE Users DROP COLUMN LastPingAt;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_350 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('3.5.0')) THEN
|
||||
UPDATE Users SET Roles = 'system_user' WHERE Roles = '';
|
||||
UPDATE Users SET Roles = 'system_user system_admin' WHERE Roles = 'system_admin';
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_350 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_350;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Position'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Users ADD Position varchar(128) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Timezone'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Users ADD Timezone varchar(256) DEFAULT \'{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}\';'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Position'
|
||||
) > 0,
|
||||
'ALTER TABLE Users MODIFY Position varchar(128);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
CREATE PROCEDURE Migrate_If_Version_Below_4100 ()
|
||||
BEGIN
|
||||
DECLARE
|
||||
CURRENT_DB_VERSION TEXT;
|
||||
SELECT
|
||||
Value
|
||||
FROM
|
||||
Systems
|
||||
WHERE
|
||||
Name = 'Version' INTO CURRENT_DB_VERSION;
|
||||
IF(INET_ATON(CURRENT_DB_VERSION) < INET_ATON('4.10.0')) THEN
|
||||
UPDATE Users SET AuthData=LOWER(AuthData) WHERE AuthService = 'saml';
|
||||
END IF;
|
||||
END;
|
||||
CALL Migrate_If_Version_Below_4100 ();
|
||||
DROP PROCEDURE IF EXISTS Migrate_If_Version_Below_4100;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT MIN(CHAR_LENGTH(Roles)) - MAX(CHAR_LENGTH(Roles))
|
||||
FROM Users
|
||||
) != 0,
|
||||
'ALTER TABLE Users MODIFY Roles varchar(256);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE updateIfMismatch FROM @preparedStatement;
|
||||
EXECUTE updateIfMismatch;
|
||||
DEALLOCATE PREPARE updateIfMismatch;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_update_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_users_update_at ON Users(UpdateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_create_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_users_create_at ON Users(CreateAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_delete_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_users_delete_at ON Users(DeleteAt);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_all_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_users_all_txt ON Users(Username, FirstName, LastName, Nickname, Email);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_all_no_full_name_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_users_all_no_full_name_txt ON Users(Username, Nickname, Email);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_names_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_users_names_txt ON Users(Username, FirstName, LastName, Nickname);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_names_no_full_name_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_users_names_no_full_name_txt ON Users(Username, Nickname);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Users ADD RemoteId VARCHAR(26);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Users'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_users_email'
|
||||
) > 0,
|
||||
'DROP INDEX idx_users_email ON Users;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,91 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'ALTER TABLE FileInfo DROP COLUMN RemoteId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_content_txt'
|
||||
) > 0,
|
||||
'DROP INDEX idx_fileinfo_content_txt ON FileInfo;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Content'
|
||||
) > 0,
|
||||
'ALTER TABLE FileInfo DROP COLUMN Content;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'MiniPreview'
|
||||
) > 0,
|
||||
'ALTER TABLE FileInfo DROP COLUMN MiniPreview;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_name_txt'
|
||||
) > 0,
|
||||
'DROP INDEX idx_fileinfo_name_txt ON FileInfo;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_extension_at'
|
||||
) > 0,
|
||||
'DROP INDEX idx_fileinfo_extension_at ON FileInfo;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS FileInfo;
|
||||
113
server/channels/db/migrations/mysql/000047_create_file_info.up.sql
Обычный файл
113
server/channels/db/migrations/mysql/000047_create_file_info.up.sql
Обычный файл
@@ -0,0 +1,113 @@
|
||||
CREATE TABLE IF NOT EXISTS FileInfo (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
PostId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
DeleteAt bigint(20) DEFAULT NULL,
|
||||
Path text,
|
||||
ThumbnailPath text,
|
||||
PreviewPath text,
|
||||
Name text,
|
||||
Extension varchar(64) DEFAULT NULL,
|
||||
Size bigint(20) DEFAULT NULL,
|
||||
MimeType text,
|
||||
Width int(11) DEFAULT NULL,
|
||||
Height int(11) DEFAULT NULL,
|
||||
HasPreviewImage tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
KEY idx_fileinfo_update_at (UpdateAt),
|
||||
KEY idx_fileinfo_create_at (CreateAt),
|
||||
KEY idx_fileinfo_delete_at (DeleteAt),
|
||||
KEY idx_fileinfo_postid_at (PostId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_extension_at'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_fileinfo_extension_at ON FileInfo (Extension);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_name_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_fileinfo_name_txt ON FileInfo (Name);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'MiniPreview'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE FileInfo ADD MiniPreview mediumblob;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Content'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE FileInfo ADD Content longtext;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_fileinfo_content_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_fileinfo_content_txt ON FileInfo (Content);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'FileInfo'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'RemoteId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE FileInfo ADD COLUMN RemoteId varchar(26);'
|
||||
));
|
||||
|
||||
PREPARE alterNotIfExists FROM @preparedStatement;
|
||||
EXECUTE alterNotIfExists;
|
||||
DEALLOCATE PREPARE alterNotIfExists;
|
||||
@@ -0,0 +1,46 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IconURL'
|
||||
) > 0,
|
||||
'ALTER TABLE OAuthApps DROP COLUMN IconURL;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IsTrusted'
|
||||
) > 0,
|
||||
'ALTER TABLE OAuthApps DROP COLUMN IsTrusted;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthapps_creator_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_oauthapps_creator_id ON OAuthApps;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
DROP TABLE IF EXISTS OAuthApps;
|
||||
@@ -0,0 +1,57 @@
|
||||
CREATE TABLE IF NOT EXISTS OAuthApps (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreatorId varchar(26) DEFAULT NULL,
|
||||
CreateAt bigint(20) DEFAULT NULL,
|
||||
UpdateAt bigint(20) DEFAULT NULL,
|
||||
ClientSecret varchar(128) DEFAULT NULL,
|
||||
Name varchar(64) DEFAULT NULL,
|
||||
Description text,
|
||||
CallbackUrls text,
|
||||
Homepage text,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_oauthapps_creator_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_oauthapps_creator_id ON OAuthApps(CreatorId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IsTrusted'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthApps ADD IsTrusted tinyint(1) DEFAULT NULL;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'OAuthApps'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'IconURL'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE OAuthApps ADD IconURL text;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
136
server/channels/db/migrations/mysql/000049_create_channels.down.sql
Обычный файл
136
server/channels/db/migrations/mysql/000049_create_channels.down.sql
Обычный файл
@@ -0,0 +1,136 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_name'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_channels_name ON Channels(Name);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Shared'
|
||||
) > 0,
|
||||
'ALTER TABLE Channels DROP COLUMN Shared;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_scheme_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_channels_scheme_id ON Channels;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT column_type FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) != 'tinyint(4)',
|
||||
'ALTER TABLE Channels MODIFY GroupConstrained tinyint(4);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfTypeDifferent FROM @preparedStatement;
|
||||
EXECUTE alterIfTypeDifferent;
|
||||
DEALLOCATE PREPARE alterIfTypeDifferent;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) > 0,
|
||||
'ALTER TABLE Channels DROP COLUMN GroupConstrained;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_channels_txt ON Channels(Name,DisplayName);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeId'
|
||||
) > 0,
|
||||
'ALTER TABLE Channels DROP COLUMN SchemeId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_displayname'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_channels_displayname ON Channels(DisplayName);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT column_type FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Purpose'
|
||||
) != 'varchar(64)',
|
||||
'ALTER TABLE Channels MODIFY Purpose varchar(64);',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfTypeDifferent FROM @preparedStatement;
|
||||
EXECUTE alterIfTypeDifferent;
|
||||
DEALLOCATE PREPARE alterIfTypeDifferent;
|
||||
|
||||
DROP TABLE IF EXISTS Channels;
|
||||
175
server/channels/db/migrations/mysql/000049_create_channels.up.sql
Обычный файл
175
server/channels/db/migrations/mysql/000049_create_channels.up.sql
Обычный файл
@@ -0,0 +1,175 @@
|
||||
CREATE TABLE IF NOT EXISTS Channels (
|
||||
Id varchar(26) NOT NULL,
|
||||
CreateAt bigint(20),
|
||||
UpdateAt bigint(20),
|
||||
DeleteAt bigint(20),
|
||||
TeamId varchar(26),
|
||||
Type varchar(1),
|
||||
DisplayName varchar(64),
|
||||
Name varchar(64),
|
||||
Header text,
|
||||
Purpose varchar(128),
|
||||
LastPostAt bigint(20),
|
||||
TotalMsgCount bigint(20),
|
||||
ExtraUpdateAt bigint(20),
|
||||
CreatorId varchar(26),
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Name (Name, TeamId),
|
||||
KEY idx_channels_team_id (TeamId),
|
||||
KEY idx_channels_name (Name),
|
||||
KEY idx_channels_update_at (UpdateAt),
|
||||
KEY idx_channels_create_at (CreateAt),
|
||||
KEY idx_channels_delete_at (DeleteAt),
|
||||
KEY idx_channels_displayname (DisplayName),
|
||||
FULLTEXT KEY idx_channels_txt (Name,DisplayName)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT column_type FROM Information_Schema.Columns
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Purpose'
|
||||
) != 'varchar(250)',
|
||||
'ALTER TABLE Channels MODIFY Purpose varchar(250)',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfTypeDifferent FROM @preparedStatement;
|
||||
EXECUTE alterIfTypeDifferent;
|
||||
DEALLOCATE PREPARE alterIfTypeDifferent;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_displayname'
|
||||
) > 0,
|
||||
'DROP INDEX idx_channels_displayname ON Channels;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Channels ADD COLUMN SchemeId varchar(26);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_txt'
|
||||
) > 0,
|
||||
'DROP INDEX idx_channels_txt ON Channels;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Channels ADD COLUMN GroupConstrained tinyint(4);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT column_type FROM Information_Schema.Columns
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'GroupConstrained'
|
||||
) != 'tinyint(1)',
|
||||
'ALTER TABLE Channels MODIFY GroupConstrained tinyint(1)',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE alterIfTypeDifferent FROM @preparedStatement;
|
||||
EXECUTE alterIfTypeDifferent;
|
||||
DEALLOCATE PREPARE alterIfTypeDifferent;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_scheme_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_channels_scheme_id ON Channels(SchemeId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channel_search_txt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE FULLTEXT INDEX idx_channel_search_txt ON Channels(Name,DisplayName,Purpose);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Shared'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Channels ADD COLUMN Shared tinyint(1);'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Channels'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_channels_name'
|
||||
) > 0,
|
||||
'DROP INDEX idx_channels_name ON Channels;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Ссылка в новой задаче
Block a user