Tristan
Tristan
DTDrizzle Team
Created by Tristan on 11/11/2024 in #help
Composite Primary Key?
In the latest versions, what would be the correct third argument of a pgTable for composite primary key? '''(t) => [ primaryKey("ContactToCompany_contactId_companyId").on( t.contactId, t.companyId, ), ],''' gets underlined unfortunately...
2 replies
DTDrizzle Team
Created by Tristan on 11/7/2024 in #help
Can i use "uniqueIndex" for that?
Hi, I was just wondering if
export const contactToCompany = pgTable(
"ContactToCompany",
{

contactId: integer().primaryKey()
companyId: integer().primaryKey()

},

(t) => [
index("ContactToCompany_contactId_companyId").on(
t.contactId,
t.companyId,
),
unique("ContactToCompany_contactId_companyId_key").on(
t.contactId,
t.companyId,
),
],
);
export const contactToCompany = pgTable(
"ContactToCompany",
{

contactId: integer().primaryKey()
companyId: integer().primaryKey()

},

(t) => [
index("ContactToCompany_contactId_companyId").on(
t.contactId,
t.companyId,
),
unique("ContactToCompany_contactId_companyId_key").on(
t.contactId,
t.companyId,
),
],
);
can be
(t) => [
uniqueIndex("ContactToCompany_contactId_companyId").on(
t.contactId,
t.companyId,
),
],
(t) => [
uniqueIndex("ContactToCompany_contactId_companyId").on(
t.contactId,
t.companyId,
),
],
Best regards, Tristan
1 replies