Depreciated table

Hi everyone, pgTable is marked here as depreciated but I can't understand why :
export const clinicsSessions = pgTable(
'clinicsSessions',
{
id: text('id')
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
year: integer('year').notNull(),
month: integer('month').notNull(),
},
(t) => ({
unq: unique().on(t.year, t.month),
})
);
export const clinicsSessions = pgTable(
'clinicsSessions',
{
id: text('id')
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
year: integer('year').notNull(),
month: integer('month').notNull(),
},
(t) => ({
unq: unique().on(t.year, t.month),
})
);
7 Replies
Ali
AliOP3w ago
the issue seems to be probably related to
(t) => ({
unq: unique().on(t.year, t.month),
})
(t) => ({
unq: unique().on(t.year, t.month),
})
because deleting it removes the depreciation warning
oke
oke3w ago
Do you have the full error message?
Ali
AliOP3w ago
const createTable: PgTableFn <"clinicsSessions", { id: IsPrimaryKey<NotNull<PgUUIDBuilderInitial<"">>>; year: NotNull<PgIntegerBuilderInitial<"">>; month: NotNull<...>; }>(name: "clinicsSessions", columns: { ...; }, extraConfig: (self: { ...; }) => PgTableExtraConfig) => PgTableWithColumns<...> (+3 overloads) @deprecated — This overload is deprecated. Use the other method overload instead.
Darren
Darren3w ago
New version uses an array now, see docs
Ali
AliOP3w ago
Drizzle ORM - Indexes & Constraints
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Ali
AliOP3w ago
it doesn't not use arrays here for example
import { integer, text, unique, pgTable } from "drizzle-orm/pg-core";
export const user = pgTable('user', {
id: integer('id').unique(),
});
export const table = pgTable('table', {
id: integer('id').unique('custom_name'),
});
export const composite = pgTable('composite_example', {
id: integer('id'),
name: text('name'),
}, (t) => ({
unq: unique().on(t.id, t.name),
unq2: unique('custom_name').on(t.id, t.name)
}));
// In Postgres 15.0+ NULLS NOT DISTINCT is available
// This example demonstrates both available usages
export const userNulls = pgTable('user_nulls_example', {
id: integer('id').unique("custom_name", { nulls: 'not distinct' }),
}, (t) => ({
unq: unique().on(t.id).nullsNotDistinct()
}));
import { integer, text, unique, pgTable } from "drizzle-orm/pg-core";
export const user = pgTable('user', {
id: integer('id').unique(),
});
export const table = pgTable('table', {
id: integer('id').unique('custom_name'),
});
export const composite = pgTable('composite_example', {
id: integer('id'),
name: text('name'),
}, (t) => ({
unq: unique().on(t.id, t.name),
unq2: unique('custom_name').on(t.id, t.name)
}));
// In Postgres 15.0+ NULLS NOT DISTINCT is available
// This example demonstrates both available usages
export const userNulls = pgTable('user_nulls_example', {
id: integer('id').unique("custom_name", { nulls: 'not distinct' }),
}, (t) => ({
unq: unique().on(t.id).nullsNotDistinct()
}));
Darren
Darren3w ago
GitHub
Release 0.36.0 · drizzle-team/drizzle-orm
This version of drizzle-orm requires [email protected] to enable all new features New Features The third parameter in Drizzle ORM becomes an array The object API is still available but deprecate...
Want results from more Discord servers?
Add your server