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!OP2y ago
@Andrew Sherman sorry for the ping but it's quite urgent
Andrii Sherman
looking into it
ethan!
ethan!OP2y ago
thank you
lanc3
lanc32y ago
You probably need to export that enum otherwise drizzle will not pick it up
Andrii Sherman
nice catch yeah didn't see export is missing
ethan!
ethan!OP2y ago
worked, thank you!

Did you find this page helpful?