Migration failure on fresh DB

I'm currently experiencing a migration failure on a fresh Postgres DB with both postgres.js and node-postgres. It's complaining that an enum I have defined in my schema (which should have created already as it's in the generated migration) does not exist.

⌛ Running Migrations
❌ Migration Failed
error: type "grandcompany" does not exist
    at Parser.parseErrorMessage (g:\code\htg-app\node_modules\.pnpm\pg-protocol@1.6.0\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (g:\code\htg-app\node_modules\.pnpm\pg-protocol@1.6.0\node_modules\pg-protocol\dist\parser.js    at Socket.<anonymous> (g:\code\htg-app\node_modules\.pnpm\pg-protocol@1.6.0\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (node:events:512:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 101,
  severity: 'ERROR',
  code: '42704',
  detail: undefined,
  hint: undefined,
  position: '1817',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_type.c',
  line: '270',
  routine: 'typenameType'
Best to post your generated migration and the relevant schema file
ASAndrii Sherman5/7/2023
Make sure you export all entities in schema file before running the migration
ASAndrii Sherman5/7/2023
Enums should also be exported
Yep, everything is exported.

import { pgEnum, pgTable, uuid, varchar } from 'drizzle-orm/pg-core';

export const grandCompany = pgEnum('grandCompany', ['Unknown', 'Maelstrom', 'Adder', 'Flames']);

export const character = pgTable('character', {
  id: uuid('id').defaultRandom().primaryKey(),
  xivId: varchar('xivId').notNull(),

  server: varchar('server').notNull(),
  dc: varchar('dc').notNull(),
  name: varchar('name').notNull(),

  grandCompany: grandCompany('grandCompany'),

 CREATE TYPE "grandCompany" AS ENUM('Unknown', 'Maelstrom', 'Adder', 'Flames');
 WHEN duplicate_object THEN null;
END $$;

    "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
    "xivId" varchar NOT NULL,
    "server" varchar NOT NULL,
    "dc" varchar NOT NULL,
    "name" varchar NOT NULL,
    "grandCompany" grandCompany
ASAndrii Sherman5/7/2023
Yeah, that’s a bug. Will fix it

2 workarounds for now
1. Change 1 param in pgEnum to “grand_company”
2. Add double quotes to grandCompany in sql file. Do it before applying to database

First should be better if you fine with snake case naming on database side
ASAndrii Sherman5/7/2023
You using latest drizzle kit version?
Awesome, thanks!

Yeah, I have drizzle kit 0.17.6 at the moment.
ASAndrii Sherman5/7/2023