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
24.55k stars 645 forks source link

[BUG]: Getting error regarding depractication when declaring pgTable #3399

Closed srkuleo closed 2 weeks ago

srkuleo commented 2 weeks ago

What version of drizzle-orm are you using?

0.36.0

What version of drizzle-kit are you using?

0.27.0

Describe the Bug

Hello, after updating to v0.36.0, I've started seeing this error message

The signature '(name: "users", columns: { id: IsPrimaryKey<NotNull<PgVarcharBuilderInitial<"", [string, ...string[]]>>>; username: NotNull<PgVarcharBuilderInitial<"", [string, ...string[]]>>; ... 4 more ...; preferences: NotNull<...>; }, extraConfig: (self: { ...; }) => PgTableExtraConfig): PgTableWithColumns<...>' of 'pgTable' is deprecated.ts(6387)
table.d.ts(26, 8): The declaration was marked as deprecated here.

My schema looks like this,

export const users = pgTable(
  "users",
  {
    id: varchar({ length: 255 }).primaryKey(),
    username: varchar({ length: 32 }).unique().notNull(),
    email: varchar({ length: 255 }).unique().notNull(),
    hashedPassword: varchar({ length: 100 }).notNull(),
    isVerified: boolean().default(false).notNull(),
    createdAt: timestamp({
      withTimezone: true,
      mode: "date",
    })
      .defaultNow()
      .notNull(),
    preferences: json().$type<UserPreferences>().notNull(),
  },
  (table) => {
    return {
      usernameIndex: index("username_index").on(table.username),
      emailIndex: index("email_index").on(table.email),
    };
  },
);

I can't seem to find anything in the docs regarding depractication and from the examples it looks like I am using the current recommended way of declaring columns inside a table.

Does anyone know how to fix this?

Expected behavior

No response

Environment & setup

No response

nicholasdly commented 2 weeks ago

Duplicating from #3335:

This is because the third parameter of pgTable should return an array now. Returning an object is deprecated as of 0.36.0.

Screenshot 2024-11-01 at 10 48 40 AM

Source: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.36.0

srkuleo commented 2 weeks ago

Duplicating from #3335:

This is because the third parameter of pgTable should return an array now. Returning an object is deprecated as of 0.36.0.

Screenshot 2024-11-01 at 10 48 40 AM

Source: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.36.0

Lol how did I miss this?? Thanks man that probably solves the issue, I will close it after checking.

Btw why did they not address this in Index and Constraints section? I haven’t seen the declaration changes there.

nicholasdly commented 2 weeks ago

The Drizzle team just had two pretty big releases, so the docs are a bit behind. I highly recommend reading the recent release notes to get up to date.

There's already a bunch of issues made for updating the docs, so we can expect the docs updated soon!

srkuleo commented 2 weeks ago

The Drizzle team just had two pretty big releases, so the docs are a bit behind. I highly recommend reading the recent release notes to get up to date.

There's already a bunch of issues made for updating the docs, so we can expect the docs updated soon!

Yeah I figured, literally read the patch notes 2 days ago not sure how I missed it :/

DePasqualeOrg commented 1 week ago

I'm getting this error in a schema that was generated after running drizzle-kit introspect. So it looks like drizzle-kit still needs to be updated to use the new format?

nicholasdly commented 1 week ago

I'm getting this error in a schema that was generated after running drizzle-kit introspect. So it looks like drizzle-kit still needs to be updated to use the new format?

I'm not really sure—might be a good opportunity for a new issue and/or PR!

BlackAdvancer commented 1 week ago

I'm getting this error in a schema that was generated after running drizzle-kit introspect. So it looks like drizzle-kit still needs to be updated to use the new format?

I'm not really sure—might be a good opportunity for a new issue and/or PR!

Same here, I am also getting the error in a schema that was generated after running drizzle-kit pull. Looks like drizzle-kit do need a update.