Enum breaking schema
Hi everyone,
In a Next.js / Vercel PostgreSQL database, I'm encountering migration errors with a part of the schema:
javascript
Copy code
export const daysOfWeekEnum = pgEnum("days_of_week", [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
]);
export const timeSlotsEnum = pgEnum("time_slots", ["morning", "afternoon", "evening"]);
export const providerAvailabilities = pgTable("provider_availabilities", {
id: serial("id").primaryKey(),
providerId: integer("provider_id")
.notNull()
.references(() => providers.id),
day: integer("day").notNull(),
timeSlot: timeSlotsEnum("time_slot").notNull(),
});
It throws this error:
vbnet
Copy code
Error: Database migration failed
error: column "day" cannot be cast automatically to type days_of_week
and this hint:
vbnet
Copy code
hint: 'You might need to specify "USING day::days_of_week".',
This column was previously an integer. If I revert back to an integer, it still throws the same error. So I'm stick.
IIf I delete the column , it still throws the error about the enum. Can anybody tell me what's going on?
Any help would be greatly appreciated.
Thanks in advance!
0 Replies