@payloadcms/db-postgres 3.0.0-alpha.38 → 3.0.0-alpha.41

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAiHrB,CAAA"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAgDrB,CAAA"}
package/dist/connect.js CHANGED
@@ -1,8 +1,7 @@
1
- import { eq, sql } from 'drizzle-orm';
1
+ import { sql } from 'drizzle-orm';
2
2
  import { drizzle } from 'drizzle-orm/node-postgres';
3
- import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core';
4
3
  import pg from 'pg';
5
- import prompts from 'prompts';
4
+ import { pushDevSchema } from './utilities/pushDevSchema.js';
6
5
  const connectWithReconnect = async function({ adapter, payload, reconnect = false }) {
7
6
  let result;
8
7
  if (!reconnect) {
@@ -74,50 +73,7 @@ export const connect = async function connect(options = {
74
73
  }
75
74
  // Only push schema if not in production
76
75
  if (process.env.NODE_ENV === 'production' || process.env.PAYLOAD_MIGRATING === 'true' || this.push === false) return;
77
- const { pushSchema } = await import('drizzle-kit/payload');
78
- // This will prompt if clarifications are needed for Drizzle to push new schema
79
- const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(this.schema, this.drizzle);
80
- if (warnings.length) {
81
- let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
82
- if (hasDataLoss) {
83
- message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
84
- }
85
- message += `Accept warnings and push schema to database?`;
86
- const { confirm: acceptWarnings } = await prompts({
87
- name: 'confirm',
88
- type: 'confirm',
89
- initial: false,
90
- message
91
- }, {
92
- onCancel: ()=>{
93
- process.exit(0);
94
- }
95
- });
96
- // Exit if user does not accept warnings.
97
- // Q: Is this the right type of exit for this interaction?
98
- if (!acceptWarnings) {
99
- process.exit(0);
100
- }
101
- }
102
- await apply();
103
- // Migration table def in order to use query using drizzle
104
- const migrationsSchema = this.pgSchema.table('payload_migrations', {
105
- name: varchar('name'),
106
- batch: numeric('batch'),
107
- created_at: timestamp('created_at'),
108
- updated_at: timestamp('updated_at')
109
- });
110
- const devPush = await this.drizzle.select().from(migrationsSchema).where(eq(migrationsSchema.batch, '-1'));
111
- if (!devPush.length) {
112
- await this.drizzle.insert(migrationsSchema).values({
113
- name: 'dev',
114
- batch: '-1'
115
- });
116
- } else {
117
- await this.drizzle.update(migrationsSchema).set({
118
- updated_at: new Date()
119
- }).where(eq(migrationsSchema.batch, '-1'));
120
- }
76
+ await pushDevSchema(this);
121
77
  };
122
78
 
123
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb25uZWN0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUGF5bG9hZCB9IGZyb20gJ3BheWxvYWQnXG5pbXBvcnQgdHlwZSB7IENvbm5lY3QgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgeyBlcSwgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgeyBkcml6emxlIH0gZnJvbSAnZHJpenpsZS1vcm0vbm9kZS1wb3N0Z3JlcydcbmltcG9ydCB7IG51bWVyaWMsIHRpbWVzdGFtcCwgdmFyY2hhciB9IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUnXG5pbXBvcnQgcGcgZnJvbSAncGcnXG5pbXBvcnQgcHJvbXB0cyBmcm9tICdwcm9tcHRzJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20g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FBQ0YsVUFBVSxJQUFJLFNBQVM7d0JBQ3RDLEVBQUUsSUFBSSxDQUFDQSxVQUFVLElBQUksU0FBUztRQUM5QyxDQUFDO2dCQUVELElBQUksQ0FBQ3RCLE9BQU8sQ0FBQ08sTUFBTSxDQUFDQyxJQUFJLENBQUM7WUFDM0I7UUFDRjtJQUNGLEVBQUUsT0FBT0gsS0FBSztRQUNaLElBQUksQ0FBQ0wsT0FBTyxDQUFDTyxNQUFNLENBQUNrQixLQUFLLENBQUMsQ0FBQyw0Q0FBNEMsRUFBRXBCLElBQUlxQixPQUFPLENBQUMsQ0FBQyxFQUFFckI7UUFDeEZjLFFBQVFRLElBQUksQ0FBQztJQUNmO0lBRUEsd0NBQXdDO0lBQ3hDLElBQ0VSLFFBQVFDLEdBQUcsQ0FBQ1EsUUFBUSxLQUFLLGdCQUN6QlQsUUFBUUMsR0FBRyxDQUFDUyxpQkFBaUIsS0FBSyxVQUNsQyxJQUFJLENBQUNDLElBQUksS0FBSyxPQUVkO0lBRUYsTUFBTWpDLGNBQWMsSUFBSTtBQUMxQixFQUFDIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI/C,eAAO,MAAM,OAAO,EAAE,OAGrB,CAAA"}
1
+ {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAM/C,eAAO,MAAM,OAAO,EAAE,OAOrB,CAAA"}
package/dist/destroy.js CHANGED
@@ -1,6 +1,11 @@
1
+ import { pushDevSchema } from './utilities/pushDevSchema.js';
1
2
  export const destroy = async function destroy() {
2
- // TODO: this hangs test suite for some reason
3
- // await this.pool.end()
3
+ if (process.env.NODE_ENV !== 'production') {
4
+ await pushDevSchema(this);
5
+ } else {
6
+ // TODO: this hangs test suite for some reason
7
+ // await this.pool.end()
8
+ }
4
9
  };
5
10
 
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZXN0cm95LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRGVzdHJveSB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuZXhwb3J0IGNvbnN0IGRlc3Ryb3k6IERlc3Ryb3kgPSBhc3luYyBmdW5jdGlvbiBkZXN0cm95KHRoaXM6IFBvc3RncmVzQWRhcHRlcikge1xuICAvLyBUT0RPOiB0aGlzIGhhbmdzIHRlc3Qgc3VpdGUgZm9yIHNvbWUgcmVhc29uXG4gIC8vIGF3YWl0IHRoaXMucG9vbC5lbmQoKVxufVxuIl0sIm5hbWVzIjpbImRlc3Ryb3kiXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sTUFBTUEsVUFBbUIsZUFBZUE7QUFDN0MsOENBQThDO0FBQzlDLHdCQUF3QjtBQUMxQixFQUFDIn0=
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZXN0cm95LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRGVzdHJveSB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgcHVzaERldlNjaGVtYSB9IGZyb20gJy4vdXRpbGl0aWVzL3B1c2hEZXZTY2hlbWEuanMnXG5cbmV4cG9ydCBjb25zdCBkZXN0cm95OiBEZXN0cm95ID0gYXN5bmMgZnVuY3Rpb24gZGVzdHJveSh0aGlzOiBQb3N0Z3Jlc0FkYXB0ZXIpIHtcbiAgaWYgKHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAncHJvZHVjdGlvbicpIHtcbiAgICBhd2FpdCBwdXNoRGV2U2NoZW1hKHRoaXMpXG4gIH0gZWxzZSB7XG4gICAgLy8gVE9ETzogdGhpcyBoYW5ncyB0ZXN0IHN1aXRlIGZvciBzb21lIHJlYXNvblxuICAgIC8vIGF3YWl0IHRoaXMucG9vbC5lbmQoKVxuICB9XG59XG4iXSwibmFtZXMiOlsicHVzaERldlNjaGVtYSIsImRlc3Ryb3kiLCJwcm9jZXNzIiwiZW52IiwiTk9ERV9FTlYiXSwibWFwcGluZ3MiOiJBQUlBLFNBQVNBLGFBQWEsUUFBUSwrQkFBOEI7QUFFNUQsT0FBTyxNQUFNQyxVQUFtQixlQUFlQTtJQUM3QyxJQUFJQyxRQUFRQyxHQUFHLENBQUNDLFFBQVEsS0FBSyxjQUFjO1FBQ3pDLE1BQU1KLGNBQWMsSUFBSTtJQUMxQixPQUFPO0lBQ0wsOENBQThDO0lBQzlDLHdCQUF3QjtJQUMxQjtBQUNGLEVBQUMifQ==
@@ -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} db - 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: (db: 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":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,OAAc,eAAe,kBAiEtD,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { eq } from 'drizzle-orm';
2
+ import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core';
3
+ import prompts from 'prompts';
4
+ const { pushSchema } = await import('drizzle-kit/payload');
5
+ /**
6
+ * Pushes the development schema to the database using Drizzle.
7
+ *
8
+ * @param {PostgresAdapter} db - The PostgresAdapter instance connected to the database.
9
+ * @returns {Promise<void>} - A promise that resolves once the schema push is complete.
10
+ */ export const pushDevSchema = async (db)=>{
11
+ // This will prompt if clarifications are needed for Drizzle to push new schema
12
+ const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(db.schema, db.drizzle);
13
+ if (warnings.length) {
14
+ let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
15
+ if (hasDataLoss) {
16
+ message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
17
+ }
18
+ message += `Accept warnings and push schema to database?`;
19
+ const { confirm: acceptWarnings } = await prompts({
20
+ name: 'confirm',
21
+ type: 'confirm',
22
+ initial: false,
23
+ message
24
+ }, {
25
+ onCancel: ()=>{
26
+ process.exit(0);
27
+ }
28
+ });
29
+ // Exit if user does not accept warnings.
30
+ // Q: Is this the right type of exit for this interaction?
31
+ if (!acceptWarnings) {
32
+ process.exit(0);
33
+ }
34
+ }
35
+ await apply();
36
+ // Migration table def in order to use query using drizzle
37
+ const migrationsSchema = db.pgSchema.table('payload_migrations', {
38
+ name: varchar('name'),
39
+ batch: numeric('batch'),
40
+ created_at: timestamp('created_at'),
41
+ updated_at: timestamp('updated_at')
42
+ });
43
+ const devPush = await db.drizzle.select().from(migrationsSchema).where(eq(migrationsSchema.batch, '-1'));
44
+ if (!devPush.length) {
45
+ await db.drizzle.insert(migrationsSchema).values({
46
+ name: 'dev',
47
+ batch: '-1'
48
+ });
49
+ } else {
50
+ await db.drizzle.update(migrationsSchema).set({
51
+ updated_at: new Date()
52
+ }).where(eq(migrationsSchema.batch, '-1'));
53
+ }
54
+ };
55
+
56
+ //# sourceMappingURL=data:application/json;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NMLEtBQUssQ0FBQ2xDLEdBQUd5QixpQkFBaUJHLEtBQUssRUFBRTtJQUN0QztBQUNGLEVBQUMifQ==
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-alpha.38",
3
+ "version": "3.0.0-alpha.41",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": "https://github.com/payloadcms/payload",
6
6
  "license": "MIT",
@@ -27,10 +27,10 @@
27
27
  "@types/pg": "8.10.2",
28
28
  "@types/to-snake-case": "1.0.0",
29
29
  "@payloadcms/eslint-config": "1.1.1",
30
- "payload": "3.0.0-alpha.38"
30
+ "payload": "3.0.0-alpha.41"
31
31
  },
32
32
  "peerDependencies": {
33
- "payload": "3.0.0-alpha.38"
33
+ "payload": "3.0.0-alpha.41"
34
34
  },
35
35
  "publishConfig": {
36
36
  "registry": "https://registry.npmjs.org/"