You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ???
The text was updated successfully, but these errors were encountered:
I don't know enough about MySQL to help you there, but I used to have a mixin which would change the value in the unique column to some random things when it was soft deleted so we could re-use the value. Of course you can't undelete it and have the value back that way, unless you have another non-unique column to backup the original value.
Thank for your reply. Currently, I dont use undelete feature and cascading soft delete. I decided to write my simple soft delete model with deleted is integer.
constraints = [ UniqueConstraint( fields=['name'], condition=Q(deleted__isnull=True), name='unique_active_name' ), ]
MySQL does not support unique constraints with conditions.
If field
deleted
werebigint
: 0 = active, others = deleted, I could create an unique constraint on name and deleted.However,
deleted
isdatetime
, null = active, unique (name, deleted) will not work.Could anyone help me ???
The text was updated successfully, but these errors were encountered: