diff --git a/server/channels/db/migrations/migrations.list b/server/channels/db/migrations/migrations.list index 60a6bc31b4..85bf564cdf 100644 --- a/server/channels/db/migrations/migrations.list +++ b/server/channels/db/migrations/migrations.list @@ -265,6 +265,8 @@ channels/db/migrations/mysql/000133_add_channel_banner_fields.down.sql channels/db/migrations/mysql/000133_add_channel_banner_fields.up.sql channels/db/migrations/mysql/000134_create_access_control_policies.down.sql channels/db/migrations/mysql/000134_create_access_control_policies.up.sql +channels/db/migrations/mysql/000135_sidebarchannels_categoryid.down.sql +channels/db/migrations/mysql/000135_sidebarchannels_categoryid.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 @@ -531,3 +533,5 @@ channels/db/migrations/postgres/000133_add_channel_banner_fields.down.sql channels/db/migrations/postgres/000133_add_channel_banner_fields.up.sql channels/db/migrations/postgres/000134_create_access_control_policies.down.sql channels/db/migrations/postgres/000134_create_access_control_policies.up.sql +channels/db/migrations/postgres/000135_sidebarchannels_categoryid.down.sql +channels/db/migrations/postgres/000135_sidebarchannels_categoryid.up.sql diff --git a/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.down.sql b/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.down.sql new file mode 100644 index 0000000000..6e65c84cf4 --- /dev/null +++ b/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.down.sql @@ -0,0 +1,14 @@ +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'SidebarChannels' + AND table_schema = DATABASE() + AND index_name = 'idx_sidebarchannels_categoryid' + ) > 0, + 'SELECT 1', + 'DROP INDEX idx_sidebarchannels_categoryid ON SidebarChannels;' +)); + +PREPARE removeIndexIfExists FROM @preparedStatement; +EXECUTE removeIndexIfExists; +DEALLOCATE PREPARE removeIndexIfExists; diff --git a/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.up.sql b/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.up.sql new file mode 100644 index 0000000000..4e4584ac63 --- /dev/null +++ b/server/channels/db/migrations/mysql/000135_sidebarchannels_categoryid.up.sql @@ -0,0 +1,14 @@ +SET @preparedStatement = (SELECT IF( + ( + SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'SidebarChannels' + AND table_schema = DATABASE() + AND index_name = 'idx_sidebarchannels_categoryid' + ) > 0, + 'SELECT 1', + 'CREATE INDEX idx_sidebarchannels_categoryid ON SidebarChannels(CategoryId);' +)); + +PREPARE createIndexIfNotExists FROM @preparedStatement; +EXECUTE createIndexIfNotExists; +DEALLOCATE PREPARE createIndexIfNotExists; diff --git a/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.down.sql b/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.down.sql new file mode 100644 index 0000000000..ad87a1b3de --- /dev/null +++ b/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.down.sql @@ -0,0 +1,2 @@ +-- morph:nontransactional +DROP INDEX CONCURRENTLY IF EXISTS idx_sidebarchannels_categoryid; diff --git a/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.up.sql b/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.up.sql new file mode 100644 index 0000000000..0c9babbdaf --- /dev/null +++ b/server/channels/db/migrations/postgres/000135_sidebarchannels_categoryid.up.sql @@ -0,0 +1,2 @@ +-- morph:nontransactional +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_sidebarchannels_categoryid ON sidebarchannels(categoryid);