Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Failed schema with d1 table #3590

Open
1 task done
ryespresso opened this issue Nov 21, 2024 · 0 comments
Open
1 task done

[BUG]: Failed schema with d1 table #3590

ryespresso opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ryespresso
Copy link

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'`),
	}
@ryespresso ryespresso added the bug Something isn't working label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant