DragonCoder99
DTDrizzle Team
•Created by DragonCoder99 on 10/18/2024 in #help
Using UUID v7 with Drizzle?
Can I use UUID V7 or some other sortable ID primary column that is not a easy number?
3 replies
DTDrizzle Team
•Created by DragonCoder99 on 10/6/2024 in #help
pgEnum + Neon migrations type error
Please someone help me, I don't understand why I'm getting this error on migrations:
This is my user schema:
NeonDbError: type "roles" does not exist
at execute (D:\PROJECT\node_modules\.pnpm\@[email protected]\node_modules\@neondatabase\serverless\index.js:1555:56)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async migrate (D:\PROJECT\node_modules\.pnpm\d[email protected]_@[email protected]_@[email protected]_@[email protected]_@xat_xasefqyfafq3r2cbdr2fxaigre\node_modules\src\neon-http\migrator.ts:47:5)
at async main (D:\PROJECT\src\db\migrate.ts:14:5) {
severity: 'ERROR',
code: '42704',
detail: undefined,
hint: undefined,
position: '203',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_type.c',
line: '270',
routine: 'typenameType',
sourceError: undefined
}
NeonDbError: type "roles" does not exist
at execute (D:\PROJECT\node_modules\.pnpm\@[email protected]\node_modules\@neondatabase\serverless\index.js:1555:56)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async migrate (D:\PROJECT\node_modules\.pnpm\d[email protected]_@[email protected]_@[email protected]_@[email protected]_@xat_xasefqyfafq3r2cbdr2fxaigre\node_modules\src\neon-http\migrator.ts:47:5)
at async main (D:\PROJECT\src\db\migrate.ts:14:5) {
severity: 'ERROR',
code: '42704',
detail: undefined,
hint: undefined,
position: '203',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_type.c',
line: '270',
routine: 'typenameType',
sourceError: undefined
}
import { createId } from "@paralleldrive/cuid2";
import {
AnyPgColumn,
boolean,
pgEnum,
pgTable,
text,
timestamp,
uniqueIndex,
varchar,
} from "drizzle-orm/pg-core";
export const RoleEnum = pgEnum("roles", ["user", "admin"]);
export const users = pgTable(
"user",
{
id: text("id")
.notNull()
.primaryKey()
.$defaultFn(() => createId()),
name: varchar("name", { length: 320 }),
email: varchar("email", { length: 320 }).notNull().unique(),
password: varchar("password", { length: 255 }),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
role: RoleEnum("roles").default("user"),
twoFactorEnabled: boolean("twoFactorEnabled").default(false),
customerID: text("customerID"),
createdAt: timestamp("created_at").defaultNow(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
})
import { createId } from "@paralleldrive/cuid2";
import {
AnyPgColumn,
boolean,
pgEnum,
pgTable,
text,
timestamp,
uniqueIndex,
varchar,
} from "drizzle-orm/pg-core";
export const RoleEnum = pgEnum("roles", ["user", "admin"]);
export const users = pgTable(
"user",
{
id: text("id")
.notNull()
.primaryKey()
.$defaultFn(() => createId()),
name: varchar("name", { length: 320 }),
email: varchar("email", { length: 320 }).notNull().unique(),
password: varchar("password", { length: 255 }),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
role: RoleEnum("roles").default("user"),
twoFactorEnabled: boolean("twoFactorEnabled").default(false),
customerID: text("customerID"),
createdAt: timestamp("created_at").defaultNow(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
})
8 replies