Skip to content

Commit

Permalink
fix: Added $defaultFn to the user table's id field when using Drizzle… (
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDevilOnLine committed Jun 3, 2024
1 parent 42a391b commit 33cdbd6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-scissors-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: Added $defaultFn to the user table's id field when using Drizzle to fix #1906
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const posts = createTable(
);

export const users = createTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
id: varchar("id", { length: 255 })
.notNull()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const posts = createTable(
);

export const users = createTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
id: varchar("id", { length: 255 })
.notNull()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const posts = createTable(
);

export const users = createTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
id: varchar("id", { length: 255 })
.notNull()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export const posts = createTable(
);

export const users = createTable("user", {
id: text("id", { length: 255 }).notNull().primaryKey(),
id: text("id", { length: 255 })
.notNull()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: text("name", { length: 255 }),
email: text("email", { length: 255 }).notNull(),
emailVerified: int("emailVerified", {
Expand Down

0 comments on commit 33cdbd6

Please sign in to comment.