Skip to content

Commit d223de4

Browse files
authored
docs: use the new pgTable signature instead deprecated (#433)
1 parent 5085da3 commit d223de4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/content/docs/indexes-constraints.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,18 @@ A `PRIMARY KEY` constraint automatically has a `UNIQUE` constraint.
216216
export const composite = pgTable('composite_example', {
217217
id: integer('id'),
218218
name: text('name'),
219-
}, (t) => ({
219+
}, (t) => [{
220220
unq: unique().on(t.id, t.name),
221221
unq2: unique('custom_name').on(t.id, t.name)
222-
}));
222+
}]);
223223

224224
// In Postgres 15.0+ NULLS NOT DISTINCT is available
225225
// This example demonstrates both available usages
226226
export const userNulls = pgTable('user_nulls_example', {
227227
id: integer('id').unique("custom_name", { nulls: 'not distinct' }),
228-
}, (t) => ({
228+
}, (t) => [{
229229
unq: unique().on(t.id).nullsNotDistinct()
230-
}));
230+
}]);
231231
```
232232

233233
```sql
@@ -411,9 +411,9 @@ If you define a `CHECK` constraint on a table it can limit the values in certain
411411
username: text().notNull(),
412412
age: integer(),
413413
},
414-
(table) => ({
414+
(table) => [{
415415
checkConstraint: check("age_check1", sql`${table.age} > 21`),
416-
})
416+
}]
417417
);
418418
```
419419
```sql
@@ -629,10 +629,10 @@ Drizzle ORM provides a standalone `primaryKey` operator for that:
629629
authorId: integer("author_id"),
630630
bookId: integer("book_id"),
631631
}, (table) => {
632-
return {
632+
return [{
633633
pk: primaryKey({ columns: [table.bookId, table.authorId] }),
634634
pkWithCustomName: primaryKey({ name: 'custom_name', columns: [table.bookId, table.authorId] }),
635-
};
635+
}];
636636
});
637637
```
638638

@@ -851,13 +851,13 @@ set return type for reference callback or use a standalone `foreignKey` operator
851851
name: text("name"),
852852
parentId: integer("parent_id"),
853853
}, (table) => {
854-
return {
854+
return [{
855855
parentReference: foreignKey({
856856
columns: [table.parentId],
857857
foreignColumns: [table.id],
858858
name: "custom_fk"
859859
}),
860-
};
860+
}];
861861
});
862862
```
863863

@@ -940,13 +940,13 @@ To declare multicolumn foreign keys you can use a dedicated `foreignKey` operato
940940
userFirstName: text("user_first_name"),
941941
userLastName: text("user_last_name"),
942942
}, (table) => {
943-
return {
943+
return [{
944944
userReference: foreignKey({
945945
columns: [table.userFirstName, table.userLastName],
946946
foreignColumns: [user.firstName, user.lastName]
947947
name: "custom_fk"
948948
})
949-
}
949+
}]
950950
})
951951
```
952952

0 commit comments

Comments
 (0)