how to use serial within compound primary key

export const refund = pgTable("refund", {
  id: serial("id").primaryKey(),
  purchase_id: integer("purchase_id")
    .references(() => purchase.id)
    .default(-1)
    .notNull(),
  order: integer("order").notNull(),
  timestamp: timestamp("timestamp").defaultNow(),
})

I want the order to go from 0 to n depending on the references shared with purchase_id
Was this page helpful?