Skip to content

[BUG]: Failed schema with d1 table #3590

Open
@ryespresso

Description

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.35.2

What version of drizzle-kit are you using?

0.26.2

Other packages

No response

Describe the Bug

CREATE TABLE "table2" (
  "column1" varchar NOT NULL DEFAULT '',
  "column2" varchar NOT NULL,
  "column3" varchar NOT NULL,
  "column4" varchar NOT NULL,
  "column5" varchar NOT NULL,
  "column6" bigint NOT NULL DEFAULT '0',
  PRIMARY KEY ("column1", "column2", "column3", "column4", "column5"),
  FOREIGN KEY ("column1") REFERENCES "table1" ("id"),
  CHECK ("column3" IN ('1', '2'))
);

When you generate the schema, you get this:

export const table2 = sqliteTable("table2", {
	column1: text("column1").default("").notNull().references(() => table1.id),
	walletAddress: text("column2").notNull(),
	walletType: text("column3").notNull(),
	contractAddress: text("column4").notNull(),
	tokenId: text("column5").notNull(),
	column6: integer().default(0).notNull(),
},
(table) => {
	return {
		pk0: primaryKey({ columns: [table.column1, table.column2, table.column3, table.column4, table.column5], name: "table2_column1_column2_column3_column4_column5_pk"}) //MISSING COMMA
		table2Check1: check("table2_check_1", sql`"column3" IN ('1', '2'`),
	}
});

Note how here is missing the comma:

return {
		pk0: primaryKey({ columns: [table.column1, table.column2, table.column3, table.column4, table.column5], name: "table2_column1_column2_column3_column4_column5_pk"}) //MISSING COMMA
		table2Check1: check("table2_check_1", sql`"column3" IN ('1', '2'`),
	}

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions