drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.54k stars 578 forks source link

[BUG]: #2256

Closed webdevcody closed 2 months ago

webdevcody commented 5 months ago

What version of drizzle-orm are you using?

0.30.9

What version of drizzle-kit are you using?

0.20.17

Describe the Bug

My config

import { env } from "@/env";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  schema: "./src/db/schema.ts",
  driver: "turso",
  out: "./drizzle",
  dbCredentials: {
    url: env.DATABASE_URL,
    authToken: env.DATABASE_AUTH_TOKEN,
  },
  verbose: true,
  strict: true,
});

I had this schema:

export const groups = sqliteTable("group", {
  id: text("id")
    .primaryKey()
    .$defaultFn(() => randomUUID()),
  name: text("name").notNull(),
  description: text("description").notNull(),
});

generated and migrated fine

then I added this column

  userId: text("userId")
    .notNull()
    .references(() => users.id, { onDelete: "cascade" }),

which generated this migration

ALTER TABLE group ADD `userId` text NOT NULL REFERENCES user(id);

this script is invalid for sqlite. I had to wrap group with group. Not sure why.

Expected behavior

No response

Environment & setup

No response

kevinmitch14 commented 4 months ago

Could be because "group" is a reserved word?

AndriiSherman commented 2 months ago

Should work fine on the latest versions, which are 0.32.0 at the time of this message