error: multiple primary keys for table "event_item_price" are not allowed
When wanting to create a composite primary key in my PG table i get an error when doing a drizzle kit push:
import { text, integer, timestamp, pgTable, primaryKey } from "drizzle-orm/pg-core";
export const metadata = {
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => new Date()),
};
export const eventItemPrice = pgTable(
"event_item_price",
{
eventId: text("event_id")
.notNull()
.references(() => event.id, { onDelete: "cascade" }),
itemId: text("item_id")
.notNull()
.references(() => item.id, { onDelete: "cascade" }),
price: integer("price"),
token_price: integer("token_price"),
...metadata,
},
(table) => [
primaryKey({ columns: [table.eventId, table.itemId] }),
]
);import { text, integer, timestamp, pgTable, primaryKey } from "drizzle-orm/pg-core";
export const metadata = {
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => new Date()),
};
export const eventItemPrice = pgTable(
"event_item_price",
{
eventId: text("event_id")
.notNull()
.references(() => event.id, { onDelete: "cascade" }),
itemId: text("item_id")
.notNull()
.references(() => item.id, { onDelete: "cascade" }),
price: integer("price"),
token_price: integer("token_price"),
...metadata,
},
(table) => [
primaryKey({ columns: [table.eventId, table.itemId] }),
]
);error: multiple primary keys for table "event_item_price" are not allowed
..........
length: 133,
severity: 'ERROR',
code: '42P16',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'index.c',
line: '217',
routine: 'index_check_primary_key'
}error: multiple primary keys for table "event_item_price" are not allowed
..........
length: 133,
severity: 'ERROR',
code: '42P16',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'index.c',
line: '217',
routine: 'index_check_primary_key'
}