Evan Deam
DTDrizzle Team
•Created by Evan Deam on 11/27/2023 in #help
'columns' does not exist in object passed to primaryKey() fn
Bootstrapped a project with CT3A@latest (drizzle-orm v ^0.28.5 in my package.json). I'm trying to create a composite primary key for a table, but the only way I've been able to get the primaryKey() function to work is to simple pass in comma separated table.columns (e.g. primaryKey(table.column1, table.column2, etc.)). I think because of the length of the column names that make up the composite primary key, I'm getting a MySQL error no. 1059 (identifier is too long).
I can do primaryKey({ name: "custom_name"}), but I'm not sure how to designate the columns I want to make up the composite key, since the TS engine is telling me 'columns' doesn't exist on this object getting passed into primaryKey(). Are the docs not update with the most recent release? Is there a way to work around this, or should I use a previous release of drizzle-orm? TIA!
3 replies