any way to force `prisma migrate` to use `UNIQUE N...
# prisma-migrate
f
any way to force
prisma migrate
to use
UNIQUE NULLS NOT DISTINCT
instead of
UNIQUE
with postgres? i need to support an existing pattern in use in our company for soft deletes by way of a "date deleted" column. the following data would be considered valid with a unique constraint on both "email" and "deleted" ... a "valid" or "undeleted" object would NOT have a value set for the
deleted
column thereby allowing the email address to be reused
Copy code
{
  id: 2,
  email: "<mailto:joe.blow@nowhere.com|joe.blow@nowhere.com>"
  created: "2022-08-11T21:12:36+00:00",
},
{
  id: 2,
  email: "<mailto:joe.blow@nowhere.com|joe.blow@nowhere.com>"
  created: "2011-1-11T11:11:11+00:00",  
  deleted: "2022-2-22T22:22:22+00:00",
}
link to a similar question on SO: https://stackoverflow.com/questions/8289100/create-unique-constraint-with-null-columns
👀 1
a
Hey Fred! You will need to customize a generated migration by running
npx prisma migrate --create-only
and adding your own custom SQL. You can read more in our docs.