Error migrating "type does not exist"

im adding more stuff to my db, so i created this type and once i wanted to migrate i got his

[⢿] applying migrations...PostgresError: type "filetype" does not exist
    at ErrorResponse (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79677:27)
    at handle (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79454:7)
    at Socket.data (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79277:9)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
    at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42704',
  file: 'parse_type.c',
  line: '270',
  routine: 'typenameType'
}

the error is pointing out the type i created as lowercase, but its camel cased
export const fileTypeEnum = pgEnum('fileType', ['image/jpeg', 'application/pdf'])

export const files = pgTable('files', {
  id: text('id').primaryKey(),
  roId: text('roId').notNull(),
  name: text('name').notNull(),
  key: text('key').notNull(),
  url: text('url').notNull(),
  type: fileTypeEnum('type').notNull(),
  createdAt: timestamp('createdAt').defaultNow().notNull()
})


the type exist in supabase, so i cant apply my other change because this one keeps on failing

DO $$ BEGIN
 CREATE TYPE "public"."fileType" AS ENUM('image/jpeg', 'application/pdf');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "files" ALTER COLUMN "type" SET DATA TYPE fileType;
Was this page helpful?