Skip to content

Commit 63bca12

Browse files
authored
docs: fix docs for generate db schema (#10251)
<!-- Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps. Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already. The following items will ensure that your PR is handled as smoothly as possible: - PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`. - Minimal description explained as if explained to someone not immediately familiar with the code. - Provide before/after screenshots or code diffs if applicable. - Link any related issues/discussions from GitHub or Discord. - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Fixes # -->
1 parent 6af6e44 commit 63bca12

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

docs/database/postgres.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,26 @@ postgresAdapter({
260260
beforeSchemaInit: [
261261
({ schema, adapter }) => {
262262
// Add a new table
263-
schema.rawTables.myTable = {
263+
adapter.rawTables.myTable = {
264264
name: 'my_table',
265-
columns: [{
266-
name: 'my_id',
267-
type: 'serial',
268-
primaryKey: true
269-
}],
265+
columns: {
266+
my_id: {
267+
name: 'my_id',
268+
type: 'serial',
269+
primaryKey: true
270+
}
271+
}
270272
}
271273

272274
// Add a new column to generated by Payload table:
273-
schema.rawTables.posts.columns.customColumn = {
275+
adapter.rawTables.posts.columns.customColumn = {
274276
name: 'custom_column',
275277
// Note that Payload SQL doesn't support everything that Drizzle does.
276278
type: 'integer',
277279
notNull: true
278280
}
279281
// Add a new index to generated by Payload table:
280-
schema.rawTables.posts.indexes.customColumnIdx = {
282+
adapter.rawTables.posts.indexes.customColumnIdx = {
281283
name: 'custom_column_idx',
282284
unique: true,
283285
on: ['custom_column']

docs/database/sqlite.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,24 +237,26 @@ sqliteAdapter({
237237
beforeSchemaInit: [
238238
({ schema, adapter }) => {
239239
// Add a new table
240-
schema.rawTables.myTable = {
240+
adapter.rawTables.myTable = {
241241
name: 'my_table',
242-
columns: [{
243-
name: 'my_id',
244-
type: 'integer',
245-
primaryKey: true
246-
}],
242+
columns: {
243+
my_id: {
244+
name: 'my_id',
245+
type: 'integer',
246+
primaryKey: true
247+
}
248+
}
247249
}
248250

249251
// Add a new column to generated by Payload table:
250-
schema.rawTables.posts.columns.customColumn = {
252+
adapter.rawTables.posts.columns.customColumn = {
251253
name: 'custom_column',
252254
// Note that Payload SQL doesn't support everything that Drizzle does.
253255
type: 'integer',
254256
notNull: true
255257
}
256258
// Add a new index to generated by Payload table:
257-
schema.rawTables.posts.indexes.customColumnIdx = {
259+
adapter.rawTables.posts.indexes.customColumnIdx = {
258260
name: 'custom_column_idx',
259261
unique: true,
260262
on: ['custom_column']

0 commit comments

Comments
 (0)