Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
unique channel names (#8439)
Conrad Irwinf27d59896fa0
diff --git a/crates/channel/src/channel_store/channel_index.rs b/crates/channel/src/channel_store/channel_index.rsindex e70b3e4c463..7e6ddd29700 100644--- a/crates/channel/src/channel_store/channel_index.rs+++ b/crates/channel/src/channel_store/channel_index.rs@@ -94,14 +94,17 @@ impl<'a> Drop for ChannelPathsInsertGuard<'a> {fn channel_path_sorting_key<'a>(id: ChannelId,channels_by_id: &'a BTreeMap<ChannelId, Arc<Channel>>,-) -> impl Iterator<Item = &str> {+) -> impl Iterator<Item = (&str, u64)> {let (parent_path, name) = channels_by_id.get(&id).map_or((&[] as &[_], None), |channel| {- (channel.parent_path.as_slice(), Some(channel.name.as_ref()))+ (+ channel.parent_path.as_slice(),+ Some((channel.name.as_ref(), channel.id)),+ )});parent_path.iter()- .filter_map(|id| Some(channels_by_id.get(id)?.name.as_ref()))+ .filter_map(|id| Some((channels_by_id.get(id)?.name.as_ref(), *id))).chain(name)}diff --git a/crates/collab/migrations/20240226164505_unique_channel_names.sql b/crates/collab/migrations/20240226164505_unique_channel_names.sqlnew file mode 100644index 00000000000..9e6a0d87618--- /dev/null+++ b/crates/collab/migrations/20240226164505_unique_channel_names.sql@@ -0,0 +1,3 @@+-- Add migration script here++CREATE UNIQUE INDEX uix_channels_parent_path_name ON channels(parent_path, name) WHERE (parent_path IS NOT NULL);