CREATE TYPE "public"."roles" AS ENUM('user', 'admin');
CREATE TABLE IF NOT EXISTS "users" (
"id" varchar(36) PRIMARY KEY NOT NULL,
"name" varchar(255) NOT NULL,
"email" varchar(255) NOT NULL,
"role" "roles" DEFAULT 'user',
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "users_email_unique" UNIQUE("email")
);
While migrating this an error came as: applying migrations...error: type "roles" does not exist
I needed to change the sql file a bit to make it work perfectly. I added few line of code which should've been added automatically.
New sql file:
CREATE TYPE "public"."roles" AS ENUM('user', 'admin');
CREATE TABLE IF NOT EXISTS "users" (
"id" varchar(36) PRIMARY KEY NOT NULL,
"name" varchar(255) NOT NULL,
"email" varchar(255) NOT NULL,
"role" "roles" DEFAULT 'user',
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "users_email_unique" UNIQUE("email")
);
// Extra lines
DO $$ BEGIN
CREATE TYPE "roles" AS ENUM('admin', 'user');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.36.1
What version of
drizzle-kit
are you using?0.28.0
Other packages
@neondatabase/serverless
Describe the Bug
Created a User Schema with
role
.Generated Migration:
While migrating this an error came as: applying migrations...error: type "roles" does not exist
I needed to change the sql file a bit to make it work perfectly. I added few line of code which should've been added automatically.
New sql file: