Invalid Input Value for Enum

Hello! I am using a enum but running into a weird issue when trying to set the value as one of options in enum. The following is the sections from my schema:

Error: Error: invalid input value for enum status: "expired"

Drizzle Schema Table:

export const discordVerification = pgTable("discord_verification", {
    code: varchar("code", { length: 255 }).notNull().primaryKey(),
    createdAt: timestamp("created_at").notNull().defaultNow(),
    clerkID: varchar("clerk_id", { length: 255 }),
    discordUserID: varchar("discord_user_id", { length: 255 }),
    discordUserTag: varchar("discord_user_tag", { length: 255 }),
    discordProfilePhoto: varchar("discord_profile_photo", { length: 255 }),
    discordName: varchar("discord_name", { length: 255 }),
    status: discordVerificationStatus("status").notNull().default("pending"),
});


Drizzle Schema Enum:
export const discordVerificationStatus = pgEnum("status", [
    "pending",
    "expired",
    "accepted",
    "rejected",
]);


Any idea why this might be? Thanks!
Solution
Update for anyone who finds this in the future, I went ahead and found the following article which I used to modify the migration. All seems to be working now!

Article: https://www.munderwood.ca/index.php/2015/05/28/altering-postgresql-columns-from-one-enum-to-another/

New Migration:

DO $$ BEGIN
 CREATE TYPE "discord_status" AS ENUM('pending', 'expired', 'accepted', 'rejected');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
 CREATE TYPE "invite_status" AS ENUM('pending', 'accepted', 'declined');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DATA TYPE discord_status USING "status"::text::discord_status;--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DEFAULT 'pending';
ALTER TABLE "invites" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "invites" ALTER COLUMN "status" SET DATA TYPE invite_status USING "status"::text::invite_status;
ALTER TABLE "invites" ALTER COLUMN "status" SET DEFAULT 'pending';
Was this page helpful?