Skip to content

Fields uniqueness with MySQL #227

Description

@kietheros

constraints = [ UniqueConstraint( fields=['name'], condition=Q(deleted__isnull=True), name='unique_active_name' ), ]

MySQL does not support unique constraints with conditions.

If field deleted were bigint: 0 = active, others = deleted, I could create an unique constraint on name and deleted.
However, deleted is datetime, null = active, unique (name, deleted) will not work.

Could anyone help me ???

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions