Drizzle TeamDT
Drizzle Team•14mo ago
nnnnnate

Drizzle studio not updating

Hello, have been trying to add to my schema file:

const RoleEnum = pgEnum("roles", ["user", "admin"]);

export const users = pgTable("user", {
  id: text("id")
    .primaryKey()
    .$defaultFn(() => crypto.randomUUID()),
  name: text("name"),
  email: text("email").unique(),
  emailVerified: timestamp("emailVerified", { mode: "date" }),
  image: text("image"),
  twoFactorEnabled: boolean("twoFactorEnabled").default(false),
  roles: RoleEnum("roles").default("user"),
});


And this is the generated SQL:

CREATE TABLE IF NOT EXISTS "user" (
    "id" text PRIMARY KEY NOT NULL,
    "name" text,
    "email" text,
    "emailVerified" timestamp,
    "image" text,
    "twoFactorEnabled" boolean DEFAULT false,
    "roles" "roles" DEFAULT 'user',
    CONSTRAINT "user_email_unique" UNIQUE("email")
);
--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;


It seems to generate and push just fine however now in drizzle studio it will not update my table. I have stopped and started my env, i have deleted everything and redone it, and im not sure as to why this is happening.

Any help appreciated 🙂
Was this page helpful?