FIX: Allow several chat channels to have an empty slug #25680
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In certain cases, chat channels may have empty slugs, it happens when:
slug_generation_method
setting is set toNone
slug_generation_method
is set toASCII
and a channel with a Unicode name and an empty slug is created (in this case, the code that creates channels tries to generate a slug and fallbacks to an empty slug)At the moment, we have a unique index on the
chat_channels.slug
column which leads to errors when creating several channels with empty slugs (Discourse is able to create one such channel, but when trying to create the second one fails because of the unique constraint). This PR fixes that by adding awhere
condition to the index. Slugs still have to be unique, but now many channels may have empty slugs.This fix is similar to the one we've made to the category slugs – 7ba914f.