@payloadcms/db-postgres 3.40.0-internal.e3ed6ab → 3.41.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +0 -6
- package/dist/connect.js.map +1 -1
- package/package.json +5 -5
package/dist/connect.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,SAAS,CAAA;AA4C1D,eAAO,MAAM,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,SAAS,CAAA;AA4C1D,eAAO,MAAM,OAAO,EAAE,OAoErB,CAAA"}
|
package/dist/connect.js
CHANGED
@@ -39,12 +39,6 @@ export const connect = async function connect(options = {
|
|
39
39
|
hotReload: false
|
40
40
|
}) {
|
41
41
|
const { hotReload } = options;
|
42
|
-
this.schema = {
|
43
|
-
pgSchema: this.pgSchema,
|
44
|
-
...this.tables,
|
45
|
-
...this.relations,
|
46
|
-
...this.enums
|
47
|
-
};
|
48
42
|
try {
|
49
43
|
if (!this.pool) {
|
50
44
|
this.pool = new this.pg.Pool(this.poolOptions);
|
package/dist/connect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration, Payload } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (ignore) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (ignore) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration, Payload } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (ignore) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (ignore) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n if (!this.pool) {\n this.pool = new this.pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle({ client: this.pool, logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n if (err.message?.match(/database .* does not exist/i) && !this.disableCreateDatabase) {\n // capitalize first char of the err msg\n this.payload.logger.info(\n `${err.message.charAt(0).toUpperCase() + err.message.slice(1)}, creating...`,\n )\n const isCreated = await this.createDatabase()\n\n if (isCreated && this.connect) {\n await this.connect(options)\n return\n }\n } else {\n this.payload.logger.error({\n err,\n msg: `Error: cannot connect to Postgres. Details: ${err.message}`,\n })\n }\n\n if (typeof this.rejectInitializing === 'function') {\n this.rejectInitializing()\n }\n process.exit(1)\n }\n\n await this.createExtensions()\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') {\n this.resolveInitializing()\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations as unknown as Migration[] })\n }\n}\n"],"names":["pushDevSchema","drizzle","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","ignore","setTimeout","logger","info","prependListener","err","code","options","hotReload","pg","Pool","poolOptions","client","schema","process","env","PAYLOAD_DROP_DATABASE","schemaName","dropDatabase","error","Error","String","message","match","disableCreateDatabase","charAt","toUpperCase","slice","isCreated","createDatabase","msg","rejectInitializing","exit","createExtensions","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"AAGA,SAASA,aAAa,QAAQ,sBAAqB;AACnD,SAASC,OAAO,QAAQ,4BAA2B;AAInD,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KA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GAAG,CAACmB,QAAQ,KAAK,gBAAgB,IAAI,CAACI,cAAc,EAAE;QAChE,MAAM,IAAI,CAACC,OAAO,CAAC;YAAEC,YAAY,IAAI,CAACF,cAAc;QAA2B;IACjF;AACF,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.41.0-canary.0",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -70,17 +70,17 @@
|
|
70
70
|
"prompts": "2.4.2",
|
71
71
|
"to-snake-case": "1.0.0",
|
72
72
|
"uuid": "10.0.0",
|
73
|
-
"@payloadcms/drizzle": "3.
|
73
|
+
"@payloadcms/drizzle": "3.41.0-canary.0"
|
74
74
|
},
|
75
75
|
"devDependencies": {
|
76
76
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
77
77
|
"@types/to-snake-case": "1.0.0",
|
78
78
|
"esbuild": "0.24.2",
|
79
|
-
"
|
80
|
-
"
|
79
|
+
"@payloadcms/eslint-config": "3.28.0",
|
80
|
+
"payload": "3.41.0-canary.0"
|
81
81
|
},
|
82
82
|
"peerDependencies": {
|
83
|
-
"payload": "3.
|
83
|
+
"payload": "3.41.0-canary.0"
|
84
84
|
},
|
85
85
|
"scripts": {
|
86
86
|
"build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
|