feat(poll): enforce active respondent uniqueness
This commit is contained in:
@@ -99,6 +99,18 @@ class PollResponse(Base, TimestampMixin):
|
||||
__table_args__ = (
|
||||
Index("ix_poll_responses_poll_submitted", "poll_id", "submitted_at"),
|
||||
Index("ix_poll_responses_poll_respondent", "poll_id", "respondent_id"),
|
||||
Index(
|
||||
"uq_poll_responses_active_respondent",
|
||||
"poll_id",
|
||||
"respondent_id",
|
||||
unique=True,
|
||||
sqlite_where=text(
|
||||
"deleted_at IS NULL AND respondent_id IS NOT NULL"
|
||||
),
|
||||
postgresql_where=text(
|
||||
"deleted_at IS NULL AND respondent_id IS NOT NULL"
|
||||
),
|
||||
),
|
||||
Index("ix_poll_responses_tenant_poll", "tenant_id", "poll_id"),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user