aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db/models.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-28 10:09:38 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-28 10:09:38 +0200
commit232ce4ae82179245b402ffc3bd473565329e5e16 (patch)
tree38cb9b1f8007009e39b462bcda16830aa2b0ede3 /packages/meshbay-hub/src/meshbay_hub/db/models.py
parent471fa6242fc56a035a8c9639722a82b9341328c2 (diff)
parent58ca879b017da62e77f40752d8d94fef3f315a1e (diff)
downloadmeshbay-232ce4ae82179245b402ffc3bd473565329e5e16.tar.gz
Merge branch 'feat/group-name-per-owner'
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/models.py')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/models.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/models.py b/packages/meshbay-hub/src/meshbay_hub/db/models.py
index 0c337c1..dbabfc2 100644
--- a/packages/meshbay-hub/src/meshbay_hub/db/models.py
+++ b/packages/meshbay-hub/src/meshbay_hub/db/models.py
@@ -15,7 +15,7 @@ from datetime import datetime, timezone
from sqlalchemy import (
Boolean, DateTime, ForeignKey, Index, Integer,
- String, Text, UniqueConstraint,
+ String, Text, UniqueConstraint, text,
)
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
@@ -109,7 +109,14 @@ class Group(Base):
members: Mapped[list["GroupMember"]] = relationship(back_populates="group")
- __table_args__ = (Index("ix_groups_name", "name"),)
+ __table_args__ = (
+ Index("ix_groups_name", "name"),
+ # One name per owner, case-insensitively. The group's identity stays its
+ # UUID; this is what makes `name@owner` a handle a human can rely on
+ # (two different owners may still both have a "photos"). Enforced in the
+ # DB so a race cannot slip a second one past the check in create_group.
+ Index("uq_groups_owner_name", "admin_id", text("lower(name)"), unique=True),
+ )
class GroupMember(Base):