Open kietheros opened 1 year ago
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 ???