How am I supposed to put unique constraints on columns

Hey! I was looking at the docs for the implementation of unique constraints and index but I think either the docs are outdated or there seems to be a bug since I could neither find the function .unique() to chain in the schema nor could I import the unqiue method from "drizzle-orm/pg-core"
6 Replies
ultrakiller
ultrakillerOP•2y ago
I am on the latest "drizzle-kit": "^0.19.12", "drizzle-orm": "^0.27.2", TS2305: Module '"drizzle-orm/pg-core"' has no exported member 'unique'.
Piotrek
Piotrek•2y ago
28.2 is the latest, not 27.2 😄 However this should still work 27.2 introduced unique it seems like... hm Can you update and restart ts server maybe?
NinjaBunny
NinjaBunny•2y ago
if that doesn't work I know you could still attach the unique index on the table
Noahh
Noahh•2y ago
This is off the top of myhead but I think the import might be uniqueIndex not unique oh nevermind?
ultrakiller
ultrakillerOP•2y ago
those are two different things afaik but updating the package and restarting the ts server several times worked! Migrated successfully. Thanks for the help ya'll :)
Noahh
Noahh•2y ago
so yeah it also exports unique, but I'm pretty sure I've seen the Drizzle team talk about how there isn't much of a difference between a unique index and a unique constraint https://discord.com/channels/1043890932593987624/1133931843377438870

Did you find this page helpful?