Enforce email uniqueness — but only among live accounts
In users we don't delete people physically — we set a deletion date in deleted_at (so-called soft-delete). But email must still be unique among the living: if Anna deleted her account, a new Anna has the right to sign up with the same email, otherwise it stays blocked forever.
Build users with id (primary key), email (up to 255 chars), and deleted_at (timestamp with timezone). Add a unique index named users_email_active_uniq over email that applies only to rows whose deleted_at is empty. Deleted rows don't enter the index, so their email can be reused.
Just CREATE/ALTER/DROP — no trailing SELECT needed.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inNo starting schema
This task starts with no tables — you'll create them via CREATE TABLE.