--
This commit is contained in:
@@ -56,15 +56,17 @@ class Headquarters(Base, UUIDMixin, TimestampMixin):
|
||||
class AMHeadquarters(Base, UUIDMixin, TimestampMixin):
|
||||
"""Which Area Manager currently manages which headquarters.
|
||||
|
||||
`effective_to IS NULL` means "current". A partial unique index guarantees at most
|
||||
one active Area Manager per headquarters at any time.
|
||||
`effective_to IS NULL` means "current". A headquarters may have several Area Managers
|
||||
and an Area Manager several headquarters; the partial unique index only stops the same
|
||||
pair being active twice.
|
||||
"""
|
||||
|
||||
__tablename__ = "am_headquarters"
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"uq_active_am_per_hq",
|
||||
"uq_active_am_hq_pair",
|
||||
"headquarters_id",
|
||||
"area_manager_user_id",
|
||||
unique=True,
|
||||
postgresql_where=text("effective_to IS NULL"),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user