@payloadcms/db-postgres 3.0.0-alpha.47 → 3.0.0-alpha.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/README.md +1 -3
  2. package/dist/create.js +2 -2
  3. package/dist/create.js.map +1 -1
  4. package/dist/createGlobal.d.ts +1 -1
  5. package/dist/createGlobal.d.ts.map +1 -1
  6. package/dist/createGlobal.js +3 -3
  7. package/dist/createGlobal.js.map +1 -1
  8. package/dist/createGlobalVersion.d.ts +1 -1
  9. package/dist/createGlobalVersion.d.ts.map +1 -1
  10. package/dist/createGlobalVersion.js +2 -2
  11. package/dist/createGlobalVersion.js.map +1 -1
  12. package/dist/createVersion.js +2 -2
  13. package/dist/createVersion.js.map +1 -1
  14. package/dist/findGlobal.js +1 -1
  15. package/dist/findGlobal.js.map +1 -1
  16. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  17. package/dist/queries/parseParams.js +1 -1
  18. package/dist/queries/parseParams.js.map +1 -1
  19. package/dist/transform/read/hasManyText.d.ts +2 -2
  20. package/dist/transform/read/hasManyText.d.ts.map +1 -1
  21. package/dist/transform/read/hasManyText.js +1 -1
  22. package/dist/transform/read/hasManyText.js.map +1 -1
  23. package/dist/transform/read/index.d.ts.map +1 -1
  24. package/dist/transform/read/index.js +2 -2
  25. package/dist/transform/read/index.js.map +1 -1
  26. package/dist/transform/read/traverseFields.d.ts.map +1 -1
  27. package/dist/transform/write/array.d.ts +2 -2
  28. package/dist/transform/write/array.d.ts.map +1 -1
  29. package/dist/transform/write/array.js +3 -3
  30. package/dist/transform/write/array.js.map +1 -1
  31. package/dist/transform/write/blocks.d.ts +2 -2
  32. package/dist/transform/write/blocks.d.ts.map +1 -1
  33. package/dist/transform/write/blocks.js +3 -3
  34. package/dist/transform/write/blocks.js.map +1 -1
  35. package/dist/transform/write/index.js +4 -4
  36. package/dist/transform/write/index.js.map +1 -1
  37. package/dist/transform/write/texts.js +2 -2
  38. package/dist/transform/write/texts.js.map +1 -1
  39. package/dist/transform/write/traverseFields.d.ts +2 -2
  40. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  41. package/dist/transform/write/traverseFields.js +21 -21
  42. package/dist/transform/write/traverseFields.js.map +1 -1
  43. package/dist/transform/write/types.d.ts +1 -1
  44. package/dist/transform/write/types.d.ts.map +1 -1
  45. package/dist/transform/write/types.js.map +1 -1
  46. package/dist/update.d.ts.map +1 -1
  47. package/dist/update.js +2 -2
  48. package/dist/update.js.map +1 -1
  49. package/dist/updateGlobal.d.ts +1 -1
  50. package/dist/updateGlobal.d.ts.map +1 -1
  51. package/dist/updateGlobal.js +3 -3
  52. package/dist/updateGlobal.js.map +1 -1
  53. package/dist/updateGlobalVersion.js +2 -2
  54. package/dist/updateGlobalVersion.js.map +1 -1
  55. package/dist/updateVersion.js +2 -2
  56. package/dist/updateVersion.js.map +1 -1
  57. package/dist/upsertRow/index.d.ts.map +1 -1
  58. package/dist/upsertRow/types.d.ts +1 -1
  59. package/dist/upsertRow/types.d.ts.map +1 -1
  60. package/dist/upsertRow/types.js.map +1 -1
  61. package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
  62. package/package.json +15 -6
  63. package/src/index.ts +150 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { TypeWithVersion, UpdateVersionArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function updateVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n id,\n collection,\n locale,\n req = {} as PayloadRequest,\n versionData,\n where: whereArg,\n }: UpdateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const whereToUse = whereArg || { id: { equals: id } }\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { where } = await buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n operation: 'update',\n tableName,\n where,\n req,\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","buildQuery","upsertRow","updateVersion","id","collection","locale","req","versionData","where","whereArg","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","whereToUse","equals","tableName","fields","adapter","result","data","operation"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,EAAE,EACFC,UAAU,EACVC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACXC,OAAOC,QAAQ,EACM;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACL,IAAIM,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMC,aAAaT,YAAY;QAAEN,IAAI;YAAEgB,QAAQhB;QAAG;IAAE;IACpD,MAAMiB,YAAY,CAAC,CAAC,EAAErB,YAAYK,YAAY,EAAE,CAAC;IACjD,MAAMiB,SAASvB,6BAA6BgB;IAE5C,MAAM,EAAEN,KAAK,EAAE,GAAG,MAAMR,WAAW;QACjCsB,SAAS,IAAI;QACbD;QACAhB;QACAe;QACAZ,OAAOU;IACT;IAEA,MAAMK,SAAS,MAAMtB,UAA8B;QACjDE;QACAmB,SAAS,IAAI;QACbE,MAAMjB;QACNG;QACAW;QACAI,WAAW;QACXL;QACAZ;QACAF;IACF;IAEA,OAAOiB;AACT"}
1
+ {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { TypeWithVersion, UpdateVersionArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function updateVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n id,\n collection,\n locale,\n req = {} as PayloadRequest,\n versionData,\n where: whereArg,\n }: UpdateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const whereToUse = whereArg || { id: { equals: id } }\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { where } = await buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n operation: 'update',\n req,\n tableName,\n where,\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","buildQuery","upsertRow","updateVersion","id","collection","locale","req","versionData","where","whereArg","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","whereToUse","equals","tableName","fields","adapter","result","data","operation"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,EAAE,EACFC,UAAU,EACVC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACXC,OAAOC,QAAQ,EACM;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACL,IAAIM,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMC,aAAaT,YAAY;QAAEN,IAAI;YAAEgB,QAAQhB;QAAG;IAAE;IACpD,MAAMiB,YAAY,CAAC,CAAC,EAAErB,YAAYK,YAAY,EAAE,CAAC;IACjD,MAAMiB,SAASvB,6BAA6BgB;IAE5C,MAAM,EAAEN,KAAK,EAAE,GAAG,MAAMR,WAAW;QACjCsB,SAAS,IAAI;QACbD;QACAhB;QACAe;QACAZ,OAAOU;IACT;IAEA,MAAMK,SAAS,MAAMtB,UAA8B;QACjDE;QACAmB,SAAS,IAAI;QACbE,MAAMjB;QACNG;QACAW;QACAI,WAAW;QACXnB;QACAc;QACAZ;IACF;IAEA,OAAOe;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAStC,eAAO,MAAM,SAAS,mHAYnB,IAAI,eAkUN,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAStC,eAAO,MAAM,SAAS,mHAYnB,IAAI,KAAG,QAAQ,CAAC,CAkUlB,CAAA"}
@@ -7,8 +7,8 @@ type BaseArgs = {
7
7
  db: DrizzleDB;
8
8
  fields: Field[];
9
9
  path?: string;
10
- tableName: string;
11
10
  req: PayloadRequest;
11
+ tableName: string;
12
12
  };
13
13
  type CreateArgs = BaseArgs & {
14
14
  id?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/upsertRow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE5E,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,eAAe,CAAA;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,EAAE,EAAE,SAAS,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,KAAK,UAAU,GAAG,QAAQ,GAAG;IAC3B,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,SAAS,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,KAAK,UAAU,GAAG,QAAQ,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/upsertRow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE5E,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,eAAe,CAAA;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,EAAE,EAAE,SAAS,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,UAAU,GAAG,QAAQ,GAAG;IAC3B,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,SAAS,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,KAAK,UAAU,GAAG,QAAQ,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, PayloadRequest } from 'payload/types'\n\nimport type { DrizzleDB, GenericColumn, PostgresAdapter } from '../types.js'\n\ntype BaseArgs = {\n adapter: PostgresAdapter\n data: Record<string, unknown>\n db: DrizzleDB\n fields: Field[]\n path?: string\n tableName: string\n req: PayloadRequest\n}\n\ntype CreateArgs = BaseArgs & {\n id?: never\n operation: 'create'\n upsertTarget?: never\n where?: never\n}\n\ntype UpdateArgs = BaseArgs & {\n id?: number | string\n operation: 'update'\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n}\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AA6BA,WAA0C"}
1
+ {"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, PayloadRequest } from 'payload/types'\n\nimport type { DrizzleDB, GenericColumn, PostgresAdapter } from '../types.js'\n\ntype BaseArgs = {\n adapter: PostgresAdapter\n data: Record<string, unknown>\n db: DrizzleDB\n fields: Field[]\n path?: string\n req: PayloadRequest\n tableName: string\n}\n\ntype CreateArgs = BaseArgs & {\n id?: never\n operation: 'create'\n upsertTarget?: never\n where?: never\n}\n\ntype UpdateArgs = BaseArgs & {\n id?: number | string\n operation: 'update'\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n}\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AA6BA,WAA0C"}
@@ -1 +1 @@
1
- {"version":3,"file":"appendPrefixToKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/appendPrefixToKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,WAAY,OAAO,MAAM,EAAE,OAAO,CAAC,UAAU,MAAM,MAI3E,CAAA"}
1
+ {"version":3,"file":"appendPrefixToKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/appendPrefixToKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,WAAY,OAAO,MAAM,EAAE,OAAO,CAAC,UAAU,MAAM,KAAG,CAI9E,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-alpha.47",
3
+ "version": "3.0.0-alpha.49",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": "https://github.com/payloadcms/payload",
6
6
  "license": "MIT",
@@ -26,14 +26,23 @@
26
26
  "devDependencies": {
27
27
  "@types/pg": "8.10.2",
28
28
  "@types/to-snake-case": "1.0.0",
29
- "@payloadcms/eslint-config": "1.1.1",
30
- "payload": "3.0.0-alpha.47"
29
+ "payload": "3.0.0-alpha.49",
30
+ "@payloadcms/eslint-config": "1.1.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "payload": "3.0.0-alpha.47"
33
+ "payload": "3.0.0-alpha.49"
34
34
  },
35
- "publishConfig": {
36
- "registry": "https://registry.npmjs.org/"
35
+ "exports": {
36
+ ".": {
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.js",
39
+ "types": "./dist/index.d.ts"
40
+ },
41
+ "./types": {
42
+ "import": "./dist/types.js",
43
+ "require": "./dist/types.js",
44
+ "types": "./dist/types.d.ts"
45
+ }
37
46
  },
38
47
  "files": [
39
48
  "dist",
package/src/index.ts ADDED
@@ -0,0 +1,150 @@
1
+ import type { Payload } from 'payload'
2
+ import type { DatabaseAdapterObj } from 'payload/database'
3
+
4
+ import fs from 'fs'
5
+ import path from 'path'
6
+ import { createDatabaseAdapter } from 'payload/database'
7
+
8
+ import type { Args, PostgresAdapter } from './types.js'
9
+
10
+ import { connect } from './connect.js'
11
+ import { create } from './create.js'
12
+ import { createGlobal } from './createGlobal.js'
13
+ import { createGlobalVersion } from './createGlobalVersion.js'
14
+ import { createMigration } from './createMigration.js'
15
+ import { createVersion } from './createVersion.js'
16
+ import { deleteMany } from './deleteMany.js'
17
+ import { deleteOne } from './deleteOne.js'
18
+ import { deleteVersions } from './deleteVersions.js'
19
+ import { destroy } from './destroy.js'
20
+ import { find } from './find.js'
21
+ import { findGlobal } from './findGlobal.js'
22
+ import { findGlobalVersions } from './findGlobalVersions.js'
23
+ import { findOne } from './findOne.js'
24
+ import { findVersions } from './findVersions.js'
25
+ import { init } from './init.js'
26
+ import { migrate } from './migrate.js'
27
+ import { migrateDown } from './migrateDown.js'
28
+ import { migrateFresh } from './migrateFresh.js'
29
+ import { migrateRefresh } from './migrateRefresh.js'
30
+ import { migrateReset } from './migrateReset.js'
31
+ import { migrateStatus } from './migrateStatus.js'
32
+ import { queryDrafts } from './queryDrafts.js'
33
+ import { beginTransaction } from './transactions/beginTransaction.js'
34
+ import { commitTransaction } from './transactions/commitTransaction.js'
35
+ import { rollbackTransaction } from './transactions/rollbackTransaction.js'
36
+ import { updateOne } from './update.js'
37
+ import { updateGlobal } from './updateGlobal.js'
38
+ import { updateGlobalVersion } from './updateGlobalVersion.js'
39
+ import { updateVersion } from './updateVersion.js'
40
+
41
+ export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
42
+
43
+ export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
44
+ function adapter({ payload }: { payload: Payload }) {
45
+ const migrationDir = findMigrationDir(args.migrationDir)
46
+ const idType = args.idType || 'serial'
47
+
48
+ return createDatabaseAdapter<PostgresAdapter>({
49
+ name: 'postgres',
50
+
51
+ // Postgres-specific
52
+ drizzle: undefined,
53
+ enums: {},
54
+ fieldConstraints: {},
55
+ idType,
56
+ logger: args.logger,
57
+ pgSchema: undefined,
58
+ pool: undefined,
59
+ poolOptions: args.pool,
60
+ push: args.push,
61
+ relations: {},
62
+ schema: {},
63
+ schemaName: args.schemaName,
64
+ sessions: {},
65
+ tables: {},
66
+
67
+ // DatabaseAdapter
68
+ beginTransaction,
69
+ commitTransaction,
70
+ connect,
71
+ create,
72
+ createGlobal,
73
+ createGlobalVersion,
74
+ createMigration,
75
+ createVersion,
76
+ /**
77
+ * This represents how a default ID is treated in Payload as were a field type
78
+ */
79
+ defaultIDType: idType === 'serial' ? 'number' : 'text',
80
+ deleteMany,
81
+ deleteOne,
82
+ deleteVersions,
83
+ destroy,
84
+ find,
85
+ findGlobal,
86
+ findGlobalVersions,
87
+ findOne,
88
+ findVersions,
89
+ init,
90
+ migrate,
91
+ migrateDown,
92
+ migrateFresh,
93
+ migrateRefresh,
94
+ migrateReset,
95
+ migrateStatus,
96
+ migrationDir,
97
+ payload,
98
+ queryDrafts,
99
+ rollbackTransaction,
100
+ updateGlobal,
101
+ updateGlobalVersion,
102
+ updateOne,
103
+ updateVersion,
104
+ })
105
+ }
106
+
107
+ return {
108
+ defaultIDType: 'number',
109
+ init: adapter,
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Attempt to find migrations directory.
115
+ *
116
+ * Checks for the following directories in order:
117
+ * - `migrationDir` argument from Payload config
118
+ * - `src/migrations`
119
+ * - `dist/migrations`
120
+ * - `migrations`
121
+ *
122
+ * Defaults to `src/migrations`
123
+ *
124
+ * @param migrationDir
125
+ * @returns
126
+ */
127
+ function findMigrationDir(migrationDir?: string): string {
128
+ const cwd = process.cwd()
129
+ const srcDir = path.resolve(cwd, 'src/migrations')
130
+ const distDir = path.resolve(cwd, 'dist/migrations')
131
+ const relativeMigrations = path.resolve(cwd, 'migrations')
132
+
133
+ // Use arg if provided
134
+ if (migrationDir) return migrationDir
135
+
136
+ // Check other common locations
137
+ if (fs.existsSync(srcDir)) {
138
+ return srcDir
139
+ }
140
+
141
+ if (fs.existsSync(distDir)) {
142
+ return distDir
143
+ }
144
+
145
+ if (fs.existsSync(relativeMigrations)) {
146
+ return relativeMigrations
147
+ }
148
+
149
+ return srcDir
150
+ }