Enum Error When Push

D:\projects\wildcard\icc2>npx drizzle-kit push    
No config path provided, using default 'drizzle.config.ts'
Reading config file 'D:\projects\wildcard\icc2\drizzle.config.ts'
Using 'pg' driver for database querying
[✓] Pulling schema from database...
error: column "role" cannot be cast automatically to type role
    at D:\projects\wildcard\icc2\node_modules\pg-pool\index.js:45:11
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.query (D:\projects\wildcard\icc2\node_modules\drizzle-kit\bin.cjs:76384:26)
    at async pgPush (D:\projects\wildcard\icc2\node_modules\drizzle-kit\bin.cjs:79407:13)
    at async Object.handler (D:\projects\wildcard\icc2\node_modules\drizzle-kit\bin.cjs:88704:9)
    at async run (D:\projects\wildcard\icc2\node_modules\drizzle-kit\bin.cjs:87030:7) {
  length: 173,
  severity: 'ERROR',
  code: '42804',
  detail: undefined,
  hint: 'You might need to specify "USING role::role".',
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'tablecmds.c',
  line: '12353',
  routine: 'ATPrepAlterColumnType'
}



import { pgTable, text, boolean, date, integer, pgEnum } from 'drizzle-orm/pg-core';
import { sql } from 'drizzle-orm';

export const enumRole = pgEnum('role', [
  'STUDENT',
  'TEACHER',
  'ADMIN'
]);

export const user = pgTable('users', {
  id: integer().primaryKey(),

  username: text().unique().notNull(),
  email: text().unique().notNull(),
  password: text().notNull(),
  isActive: boolean().default(false),
  role: enumRole(),

  avatar: text(),
  banner: text(),
  fullName: text(),
  bio: text(),

  createdAt: date().default(sql`CURRENT_TIMESTAMP`),
  updatedAt: date().default(sql`CURRENT_TIMESTAMP`).$onUpdate(() => sql`CURRENT_TIMESTAMP`),
});
Was this page helpful?