SQLite composite primary key error.

I'm trying to add a composite primary key for the following table but I'm getting a type error. I've referenced the docs and this looks to be the correct syntax so I'm just a little confused. https://orm.drizzle.team/docs/indexes-constraints#composite-primary-key

    "drizzle-orm": "^0.28.6",


Error:
Argument of type '{ columns: (SQLiteColumn<{ name: "event_id"; tableName: "latest_odds"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [string, ...string[]]; baseColumn: never; }, object> | SQLiteColumn<...> | SQLiteColumn<...> | SQLiteColumn<...>)[]; }' is not assignable to parameter of type 'AnySQLiteColumn<{ tableName: string; }>'.
  Object literal may only specify known properties, and 'columns' does not exist in type 'SQLiteColumn<Required<{ name: string; dataType: ColumnDataType; columnType: string; data: unknown; driverParam: unknown; notNull: boolean; hasDefault: boolean; enumValues: string[] | undefined; tableName: string; }>, object>'


Schema Def:
import {
  index,
  integer,
  primaryKey,
  real,
  sqliteTable,
  text,
} from "drizzle-orm/sqlite-core";

export const LatestOdds = sqliteTable(
  "latest_odds",
  {
    eventId: text("event_id").notNull(),
    eventName: text("event_name"),
    marketId: text("market_id").notNull(),
    marketName: text("market_name"),
    outcomeId: text("outcome_id").notNull(),
    outcome: text("outcome").notNull(),
    oddsDecimal: real("odds_decimal"),
    oddsFractional: text("odds_fractional"),
    timestamp: integer("timestamp", { mode: "timestamp_ms" })
      .default(sql`CURRENT_TIMESTAMP`)
      .notNull(),
    bookmaker: text("bookmaker").notNull(),
  },
  (table) => {
    return {
      pk: primaryKey({
        columns: [
          table.eventId,
          table.marketId,
          table.outcomeId,
          table.bookmaker,
        ],
      }),
    };
  }
);
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?