drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]:

Open webdevcody opened this issue 1 year ago • 1 comments

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

webdevcody avatar May 04 '24 21:05 webdevcody

Could be because "group" is a reserved word?

kevinmitch14 avatar May 09 '24 19:05 kevinmitch14

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

AndriiSherman avatar Jul 11 '24 09:07 AndriiSherman