@payloadcms/db-postgres 0.8.6 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +5 -52
  3. package/dist/count.d.ts.map +1 -1
  4. package/dist/count.js +3 -3
  5. package/dist/createMigration.d.ts.map +1 -1
  6. package/dist/createMigration.js +10 -4
  7. package/dist/find/buildFindManyArgs.d.ts.map +1 -1
  8. package/dist/find/buildFindManyArgs.js +2 -1
  9. package/dist/find/findMany.d.ts.map +1 -1
  10. package/dist/find/findMany.js +3 -3
  11. package/dist/find/traverseFields.d.ts +2 -1
  12. package/dist/find/traverseFields.d.ts.map +1 -1
  13. package/dist/find/traverseFields.js +9 -3
  14. package/dist/init.js +3 -2
  15. package/dist/migrate.js +3 -3
  16. package/dist/migrateDown.js +2 -2
  17. package/dist/migrateRefresh.js +2 -2
  18. package/dist/migrateReset.js +3 -3
  19. package/dist/migrateStatus.js +2 -2
  20. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  21. package/dist/queries/getTableColumnFromPath.js +4 -3
  22. package/dist/queries/parseParams.d.ts.map +1 -1
  23. package/dist/queries/parseParams.js +3 -1
  24. package/dist/queries/sanitizeQueryValue.d.ts +2 -1
  25. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  26. package/dist/queries/sanitizeQueryValue.js +11 -2
  27. package/dist/schema/build.d.ts +10 -2
  28. package/dist/schema/build.d.ts.map +1 -1
  29. package/dist/schema/build.js +23 -6
  30. package/dist/schema/traverseFields.d.ts +6 -1
  31. package/dist/schema/traverseFields.d.ts.map +1 -1
  32. package/dist/schema/traverseFields.js +46 -17
  33. package/dist/transform/read/hasManyNumber.d.ts +2 -1
  34. package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
  35. package/dist/transform/read/hasManyNumber.js +14 -4
  36. package/dist/transform/read/hasManyText.d.ts +2 -1
  37. package/dist/transform/read/hasManyText.d.ts.map +1 -1
  38. package/dist/transform/read/hasManyText.js +14 -4
  39. package/dist/transform/read/relationship.d.ts +2 -1
  40. package/dist/transform/read/relationship.d.ts.map +1 -1
  41. package/dist/transform/read/relationship.js +16 -7
  42. package/dist/transform/read/traverseFields.d.ts +5 -1
  43. package/dist/transform/read/traverseFields.d.ts.map +1 -1
  44. package/dist/transform/read/traverseFields.js +118 -85
  45. package/dist/transform/write/array.d.ts +6 -1
  46. package/dist/transform/write/array.d.ts.map +1 -1
  47. package/dist/transform/write/array.js +7 -3
  48. package/dist/transform/write/blocks.d.ts +6 -1
  49. package/dist/transform/write/blocks.d.ts.map +1 -1
  50. package/dist/transform/write/blocks.js +5 -3
  51. package/dist/transform/write/traverseFields.d.ts +6 -1
  52. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  53. package/dist/transform/write/traverseFields.js +40 -15
  54. package/dist/types.d.ts +9 -5
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/upsertRow/insertArrays.d.ts.map +1 -1
  57. package/dist/upsertRow/insertArrays.js +5 -2
  58. package/dist/utilities/migrationTableExists.d.ts +2 -2
  59. package/dist/utilities/migrationTableExists.d.ts.map +1 -1
  60. package/dist/utilities/migrationTableExists.js +10 -6
  61. package/dist/utilities/pushDevSchema.d.ts +9 -0
  62. package/dist/utilities/pushDevSchema.d.ts.map +1 -0
  63. package/dist/utilities/pushDevSchema.js +59 -0
  64. package/dist/utilities/requireDrizzleKit.d.ts +14 -0
  65. package/dist/utilities/requireDrizzleKit.d.ts.map +1 -0
  66. package/dist/utilities/requireDrizzleKit.js +13 -0
  67. package/package.json +6 -6
@@ -36,7 +36,10 @@ const insertArrays = async ({ adapter, arrays, db, parentRows })=>{
36
36
  arrayRowLocaleData._locale = arrayRowLocale;
37
37
  rowsByTable[tableName].locales.push(arrayRowLocaleData);
38
38
  if (!arrayRow.row.id) {
39
- arrayRowLocaleData._getParentID = (rows)=>rows[i].id;
39
+ arrayRowLocaleData._getParentID = (rows)=>{
40
+ const { id } = rows.find((each)=>each._uuid === arrayRow.row._uuid);
41
+ return id;
42
+ };
40
43
  }
41
44
  });
42
45
  });
@@ -75,4 +78,4 @@ const insertArrays = async ({ adapter, arrays, db, parentRows })=>{
75
78
  }
76
79
  };
77
80
 
78
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91cHNlcnRSb3cvaW5zZXJ0QXJyYXlzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXBhcmFtLXJlYXNzaWduICovXG5pbXBvcnQgdHlwZSB7IEFycmF5Um93VG9JbnNlcnQgfSBmcm9tICcuLi90cmFuc2Zvcm0vd3JpdGUvdHlwZXMnXG5pbXBvcnQgdHlwZSB7IERyaXp6bGVEQiwgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMnXG5cbnR5cGUgQXJncyA9IHtcbiAgYWRhcHRlcjogUG9zdGdyZXNBZGFwdGVyXG4gIGFycmF5czoge1xuICAgIFt0YWJsZU5hbWU6IHN0cmluZ106IEFycmF5Um93VG9JbnNlcnRbXVxuICB9W11cbiAgZGI6IERyaXp6bGVEQlxuICBwYXJlbnRSb3dzOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdXG59XG5cbnR5cGUgUm93c0J5VGFibGUgPSB7XG4gIFt0YWJsZU5hbWU6IHN0cmluZ106IHtcbiAgICBhcnJheXM6IHtcbiAgICAgIFt0YWJsZU5hbWU6IHN0cmluZ106IEFycmF5Um93VG9JbnNlcnRbXVxuICAgIH1bXVxuICAgIGxvY2FsZXM6IFJlY29yZDxzdHJpbmcsIHVua25vd24+W11cbiAgICByb3dzOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdXG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IGluc2VydEFycmF5cyA9IGFzeW5jICh7IGFkYXB0ZXIsIGFycmF5cywgZGIsIHBhcmVudFJvd3MgfTogQXJncyk6IFByb21pc2U8dm9pZD4gPT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@
1
- import type { DrizzleDB } from '../types';
2
- export declare const migrationTableExists: (db: DrizzleDB) => Promise<boolean>;
1
+ import type { PostgresAdapter } from '../types.js';
2
+ export declare const migrationTableExists: (adapter: PostgresAdapter) => Promise<boolean>;
3
3
  //# sourceMappingURL=migrationTableExists.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,eAAO,MAAM,oBAAoB,qBAA0B,QAAQ,OAAO,CAMzE,CAAA"}
1
+ {"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,oBAAoB,YAAmB,eAAe,KAAG,QAAQ,OAAO,CAapF,CAAA"}
@@ -9,11 +9,15 @@ Object.defineProperty(exports, "migrationTableExists", {
9
9
  }
10
10
  });
11
11
  const _drizzleorm = require("drizzle-orm");
12
- const migrationTableExists = async (db)=>{
13
- const queryRes = await db.execute((0, _drizzleorm.sql)`SELECT to_regclass('public.payload_migrations');`);
14
- // Returns table name 'payload_migrations' or null
15
- const exists = queryRes.rows?.[0]?.to_regclass === 'payload_migrations';
16
- return exists;
12
+ const migrationTableExists = async (adapter)=>{
13
+ let statement;
14
+ if (adapter.name === 'postgres') {
15
+ const prependSchema = adapter.schemaName ? `"${adapter.schemaName}".` : '';
16
+ statement = `SELECT to_regclass('${prependSchema}"payload_migrations"') AS exists;`;
17
+ }
18
+ const result = await adapter.drizzle.execute(_drizzleorm.sql.raw(statement));
19
+ const [row] = result.rows;
20
+ return row && typeof row === 'object' && 'exists' in row && !!row.exists;
17
21
  };
18
22
 
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi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W1lIiwicHJlcGVuZFNjaGVtYSIsInNjaGVtYU5hbWUiLCJyZXN1bHQiLCJkcml6emxlIiwiZXhlY3V0ZSIsInNxbCIsInJhdyIsInJvdyIsInJvd3MiLCJleGlzdHMiXSwicmFuZ2VNYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7IiwibWFwcGluZ3MiOiI7Ozs7K0JBSWFBOzs7ZUFBQUE7Ozs0QkFKTztBQUliLE1BQU1BLHVCQUF1QixPQUFPQztJQUN6QyxJQUFJQztJQUVKLElBQUlELFFBQVFFLElBQUksS0FBSyxZQUFZO1FBQy9CLE1BQU1DLGdCQUFnQkgsUUFBUUksVUFBVSxHQUFHLENBQUMsQ0FBQyxFQUFFSixRQUFRSSxVQUFVLENBQUMsRUFBRSxDQUFDLEdBQUc7UUFDeEVILFlBQVksQ0FBQyxvQkFBb0IsRUFBRUUsY0FBYyxpQ0FBaUMsQ0FBQztJQUNyRjtJQUVBLE1BQU1FLFNBQVMsTUFBTUwsUUFBUU0sT0FBTyxDQUFDQyxPQUFPLENBQUNDLGVBQUcsQ0FBQ0MsR0FBRyxDQUFDUjtJQUVyRCxNQUFNLENBQUNTLElBQUksR0FBR0wsT0FBT00sSUFBSTtJQUV6QixPQUFPRCxPQUFPLE9BQU9BLFFBQVEsWUFBWSxZQUFZQSxPQUFPLENBQUMsQ0FBQ0EsSUFBSUUsTUFBTTtBQUMxRSJ9
@@ -0,0 +1,9 @@
1
+ import type { PostgresAdapter } from '../types.js';
2
+ /**
3
+ * Pushes the development schema to the database using Drizzle.
4
+ *
5
+ * @param {PostgresAdapter} adapter - The PostgresAdapter instance connected to the database.
6
+ * @returns {Promise<void>} - A promise that resolves once the schema push is complete.
7
+ */
8
+ export declare const pushDevSchema: (adapter: PostgresAdapter) => Promise<void>;
9
+ //# sourceMappingURL=pushDevSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAmB,eAAe,kBA8D3D,CAAA"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "pushDevSchema", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return pushDevSchema;
9
+ }
10
+ });
11
+ const _drizzleorm = require("drizzle-orm");
12
+ const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
13
+ const _requireDrizzleKit = require("./requireDrizzleKit");
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ const pushDevSchema = async (adapter)=>{
20
+ const { pushSchema } = (0, _requireDrizzleKit.requireDrizzleKit)();
21
+ // This will prompt if clarifications are needed for Drizzle to push new schema
22
+ const { apply, hasDataLoss, warnings } = await pushSchema(adapter.schema, adapter.drizzle, adapter.schemaName ? [
23
+ adapter.schemaName
24
+ ] : undefined);
25
+ if (warnings.length) {
26
+ let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
27
+ if (hasDataLoss) {
28
+ message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
29
+ }
30
+ message += `Accept warnings and push schema to database?`;
31
+ const { confirm: acceptWarnings } = await (0, _prompts.default)({
32
+ name: 'confirm',
33
+ type: 'confirm',
34
+ initial: false,
35
+ message
36
+ }, {
37
+ onCancel: ()=>{
38
+ process.exit(0);
39
+ }
40
+ });
41
+ // Exit if user does not accept warnings.
42
+ // Q: Is this the right type of exit for this interaction?
43
+ if (!acceptWarnings) {
44
+ process.exit(0);
45
+ }
46
+ }
47
+ await apply();
48
+ const migrationsTable = adapter.schemaName ? `"${adapter.schemaName}"."payload_migrations"` : '"payload_migrations"';
49
+ const { drizzle } = adapter;
50
+ const result = await drizzle.execute(_drizzleorm.sql.raw(`SELECT * FROM ${migrationsTable} WHERE batch = '-1'`));
51
+ const devPush = result.rows;
52
+ if (!devPush.length) {
53
+ await drizzle.execute(_drizzleorm.sql.raw(`INSERT INTO ${migrationsTable} (name, batch) VALUES ('dev', '-1')`));
54
+ } else {
55
+ await drizzle.execute(_drizzleorm.sql.raw(`UPDATE ${migrationsTable} SET updated_at = CURRENT_TIMESTAMP WHERE batch = '-1'`));
56
+ }
57
+ };
58
+
59
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcHVzaERldlNjaGVtYS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBzcWwgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5cbmltcG9ydCB7IHJlcXVpcmVEcml6emxlS2l0IH0gZnJvbSAnLi9yZXF1aXJlRHJpenpsZUtpdCdcblxuLyoqXG4gKiBQdXNoZXMgdGhlIGRldmVsb3BtZW50IHNjaGVtYSB0byB0aGUgZGF0YWJhc2UgdXNpbmcgRHJpenpsZS5cbiAqXG4gKiBAcGFyYW0ge1Bvc3RncmVzQWRhcHRlcn0gYWRhcHRlciAtIFRoZSBQb3N0Z3Jlc0FkYXB0ZXIgaW5zdGFuY2UgY29ubmVjdGVkIHRvIHRoZSBkYXRhYmFzZS5cbiAqIEByZXR1cm5zIHtQcm9taXNlPHZvaWQ+fSAtIEEgcHJvbWlzZSB0aGF0IHJlc29sdmVzIG9uY2UgdGhlIHNjaGVtYSBwdXNoIGlzIGNvbXBsZXRlLlxuICovXG5leHBvcnQgY29uc3QgcHVzaERldlNjaGVtYSA9IGFzeW5jIChhZGFwdGVyOiBQb3N0Z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VKLGdCQUFnQixtQ0FBbUMsQ0FBQztJQUUvRSxPQUFPO1FBQ0wsTUFBTWYsUUFBUWlCLE9BQU8sQ0FDbkJDLGVBQUcsQ0FBQ0MsR0FBRyxDQUFDLENBQUMsT0FBTyxFQUFFSixnQkFBZ0Isc0RBQXNELENBQUM7SUFFN0Y7QUFDRiJ9
@@ -0,0 +1,14 @@
1
+ import type { PostgresAdapter } from '../types';
2
+ type RequireDrizzleKit = () => {
3
+ generateDrizzleJson: (args: {
4
+ schema: Record<string, unknown>;
5
+ }) => unknown;
6
+ pushSchema: (schema: Record<string, unknown>, drizzle: PostgresAdapter['drizzle'], filterSchema?: string[]) => Promise<{
7
+ apply: any;
8
+ hasDataLoss: any;
9
+ warnings: any;
10
+ }>;
11
+ };
12
+ export declare const requireDrizzleKit: RequireDrizzleKit;
13
+ export {};
14
+ //# sourceMappingURL=requireDrizzleKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../../src/utilities/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,iBAAiB,GAAG,MAAM;IAC7B,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,CAAA;IAC3E,UAAU,EAAE,CACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,EACnC,YAAY,CAAC,EAAE,MAAM,EAAE,KACpB,OAAO,CAAC;QAAE,KAAK,MAAC;QAAC,WAAW,MAAC;QAAC,QAAQ,MAAA;KAAE,CAAC,CAAA;CAC/C,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,iBAAoD,CAAA"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "requireDrizzleKit", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return requireDrizzleKit;
9
+ }
10
+ });
11
+ const requireDrizzleKit = ()=>require('drizzle-kit/api');
12
+
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcmVxdWlyZURyaXp6bGVLaXQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuLi90eXBlcydcblxudHlwZSBSZXF1aXJlRHJpenpsZUtpdCA9ICgpID0+IHtcbiAgZ2VuZXJhdGVEcml6emxlSnNvbjogKGFyZ3M6IHsgc2NoZW1hOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPiB9KSA9PiB1bmtub3duXG4gIHB1c2hTY2hlbWE6IChcbiAgICBzY2hlbWE6IFJlY29yZDxzdHJpbmcsIHVua25vd24+LFxuICAgIGRyaXp6bGU6IFBvc3RncmVzQWRhcHRlclsnZHJpenpsZSddLFxuICAgIGZpbHRlclNjaGVtYT86IHN0cmluZ1tdLFxuICApID0+IFByb21pc2U8eyBhcHBseTsgaGFzRGF0YUxvc3M7IHdhcm5pbmdzIH0+XG59XG5cbmV4cG9ydCBjb25zdCByZXF1aXJlRHJpenpsZUtpdDogUmVxdWlyZURyaXp6bGVLaXQgPSAoKSA9PiByZXF1aXJlKCdkcml6emxlLWtpdC9hcGknKVxuIl0sIm5hbWVzIjpbInJlcXVpcmVEcml6emxlS2l0IiwicmVxdWlyZSJdLCJyYW5nZU1hcHBpbmdzIjoiOzs7Ozs7Ozs7OyIsIm1hcHBpbmdzIjoiOzs7OytCQVdhQTs7O2VBQUFBOzs7QUFBTixNQUFNQSxvQkFBdUMsSUFBTUMsUUFBUSJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,18 +19,18 @@
19
19
  "dependencies": {
20
20
  "@libsql/client": "^0.3.1",
21
21
  "console-table-printer": "2.11.2",
22
- "drizzle-kit": "0.20.14-1f2c838",
23
- "drizzle-orm": "0.29.3",
22
+ "drizzle-kit": "0.23.2-df9e596",
23
+ "drizzle-orm": "0.32.1",
24
24
  "pg": "8.11.3",
25
25
  "prompts": "2.4.2",
26
26
  "to-snake-case": "1.0.0",
27
- "uuid": "9.0.0"
27
+ "uuid": "10.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/pg": "8.10.2",
31
31
  "@types/to-snake-case": "1.0.0",
32
- "payload": "2.28.0",
33
- "@payloadcms/eslint-config": "1.1.1"
32
+ "@payloadcms/eslint-config": "1.1.1",
33
+ "payload": "2.30.2"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "payload": "^2.0.0"