feat: group name unique per org
Instead of group names being wholly unique (enforced by the db), group names are unique within the org (enforced by endpoint logic).
This commit is contained in:
parent
3f7abc5986
commit
dad23733e8
3 changed files with 52 additions and 1 deletions
|
|
@ -56,10 +56,18 @@ class Permission(Base):
|
|||
class Group(Base):
|
||||
__tablename__ = "group"
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String, nullable=False, unique=True)
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
org_id = Column(Integer, ForeignKey("organisation.id", ondelete="CASCADE"))
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"name",
|
||||
"org_id",
|
||||
name="uniq_group_name_org_id",
|
||||
),
|
||||
)
|
||||
|
||||
user_rel = relationship("User", secondary="user_groups", back_populates="group_rel")
|
||||
|
||||
org_rel = relationship("Organisation", back_populates="group_rel")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue