[Postgres] PostgresError: type X already exists.

PostgresError: type "media_types" already exists
PostgresError: type "media_types" already exists
I have SQL like this: CREATE TYPE "public"."media_types" AS ENUM('image', 'video');--> sta It's used only here:
CREATE TABLE IF NOT EXISTS "media" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"url" text NOT NULL,
"filename" text NOT NULL,
"mediaType" "media_types" NOT NULL,
CREATE TABLE IF NOT EXISTS "media" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"url" text NOT NULL,
"filename" text NOT NULL,
"mediaType" "media_types" NOT NULL,
My schema is:
export const mediaTypes = z.enum(["image", "video"]);
export type MediaType = z.infer<typeof mediaTypes>;
export const mediaType = pgEnum("media_types", mediaTypes.options);

export const TB_Media = pgTable("media", {
id: text().primaryKey().notNull().$defaultFn(nanoid),
name: text().notNull(),

url: text().notNull().unique(),
filename: text().notNull(),

mediaType: mediaType().notNull(),
export const mediaTypes = z.enum(["image", "video"]);
export type MediaType = z.infer<typeof mediaTypes>;
export const mediaType = pgEnum("media_types", mediaTypes.options);

export const TB_Media = pgTable("media", {
id: text().primaryKey().notNull().$defaultFn(nanoid),
name: text().notNull(),

url: text().notNull().unique(),
filename: text().notNull(),

mediaType: mediaType().notNull(),
This all happend after using casting to "snake_case"
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server