Enums

const validStatuses = ["claimed", "confirmed", "started"] as const;
const statusEnum = pgEnum("status", validStatuses);
export type SessionStatus = typeof validStatuses[number];

export const trainingsTable = pgTable("training", {
date: text("date").primaryKey(),
host: text("host").notNull(),
status: statusEnum("status").notNull(),
notificationID: text("notification_id"),
notificationDeletionDate: timestamp("notification_deletion_date")
});
const validStatuses = ["claimed", "confirmed", "started"] as const;
const statusEnum = pgEnum("status", validStatuses);
export type SessionStatus = typeof validStatuses[number];

export const trainingsTable = pgTable("training", {
date: text("date").primaryKey(),
host: text("host").notNull(),
status: statusEnum("status").notNull(),
notificationID: text("notification_id"),
notificationDeletionDate: timestamp("notification_deletion_date")
});
When I run drizzle-kit push --config=src/db/config.ts it returns error: type "status" does not exist, how do I fix this?
6 Replies
ethan!
ethan!OP8mo ago
@Andrew Sherman sorry for the ping but it's quite urgent
Andrii Sherman
Andrii Sherman8mo ago
looking into it
ethan!
ethan!OP8mo ago
thank you
lanc3
lanc38mo ago
You probably need to export that enum otherwise drizzle will not pick it up
Andrii Sherman
Andrii Sherman8mo ago
nice catch yeah didn't see export is missing
ethan!
ethan!OP8mo ago
worked, thank you!

Did you find this page helpful?