How do I keep a unique constraint on a column like email while using soft deletes?
Use a partial unique index on deleted_at IS NULL in PostgreSQL and a generated column in MySQL, adding app validation beside the constraint, not instead.
Tag
Tables, relations and types: shaping data around the questions it will answer. questions under this tag, answered directly.
2 answered questions carry this tag.
Use a partial unique index on deleted_at IS NULL in PostgreSQL and a generated column in MySQL, adding app validation beside the constraint, not instead.
With 3 stable types and a real need for foreign keys, use a single-table exclusive arc; if the type set is open-ended, go pure morph with a morph map.