Does anyone know how to create a table with a
WHEN
sql tag?
i want a table like this
"members_table", { id: serial("id").primaryKey(), email: text("email").notNull(), team_id: text("team_id").notNull(), deleted_at: timestamp("deleted_at"), },
Where i want unique to be like this
CREATE UNIQUE INDEX email_team_id_unique_idx ON members_table (email, team_id) WHERE deleted_at IS NULL;
but in drizzle. Is that possible?
I want it to be that i cannot have the same mail and team_id twice. So [email protected] cannot be in team_id A and B, but can have [email protected] be in A and have deleted_at with NULL data, and have a [email protected] be in A and have deleted_at with aug 15th 2024 at the same time. If that makes sense.
Im using Next.js, Neon, postgreSQL if that have anything to do with it 🙂
i feel like i have tried a lot, but nothing at the same time. I am very new to drizzle and there is a LOT in the docs so its hard to find exactly what i am looking for. But any idea is good, there is a good chance that any one you know more than me xD
Oscar Alsos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1