Fred Lackey
08/11/2022, 9:55 PMprisma 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
{
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-columnsAustin
08/15/2022, 7:34 PMnpx prisma migrate --create-only
and adding your own custom SQL.
You can read more in our docs.