@payloadcms/db-postgres 0.1.0-beta.14 → 0.1.0-beta.16
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +8 -18
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/migrate.js +2 -2
- package/dist/migrateDown.d.ts +3 -0
- package/dist/migrateDown.d.ts.map +1 -0
- package/dist/migrateDown.js +71 -0
- package/dist/migrateFresh.d.ts +6 -0
- package/dist/migrateFresh.d.ts.map +1 -0
- package/dist/migrateFresh.js +81 -0
- package/dist/migrateRefresh.d.ts +6 -0
- package/dist/migrateRefresh.d.ts.map +1 -0
- package/dist/migrateRefresh.js +114 -0
- package/dist/migrateReset.d.ts +6 -0
- package/dist/migrateReset.d.ts.map +1 -0
- package/dist/migrateReset.js +87 -0
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +11 -3
- package/dist/utilities/migrations.d.ts +0 -15
- package/dist/utilities/migrations.d.ts.map +0 -1
- package/dist/utilities/migrations.js +0 -85
package/dist/connect.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAW/C,eAAO,MAAM,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAW/C,eAAO,MAAM,OAAO,EAAE,OA0FrB,CAAA"}
|
package/dist/connect.js
CHANGED
@@ -26,45 +26,35 @@ const connect = async function connect(payload) {
|
|
26
26
|
...this.enums
|
27
27
|
};
|
28
28
|
try {
|
29
|
-
this.pool = new _pg.Pool(this.
|
29
|
+
this.pool = new _pg.Pool(this.poolOptions);
|
30
30
|
await this.pool.connect();
|
31
31
|
this.drizzle = (0, _nodepostgres.drizzle)(this.pool, {
|
32
32
|
schema: this.schema
|
33
33
|
});
|
34
34
|
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
|
35
35
|
this.payload.logger.info('---- DROPPING TABLES ----');
|
36
|
-
await this.drizzle.execute((0, _drizzleorm.sql)`drop schema public cascade
|
36
|
+
await this.drizzle.execute((0, _drizzleorm.sql)`drop schema public cascade;
|
37
|
+
create schema public;`);
|
37
38
|
this.payload.logger.info('---- DROPPED TABLES ----');
|
38
39
|
}
|
39
40
|
} catch (err) {
|
40
41
|
payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err);
|
41
42
|
process.exit(1);
|
42
43
|
}
|
43
|
-
this.payload.logger.info('Connected to Postgres successfully');
|
44
44
|
// Only push schema if not in production
|
45
45
|
if (process.env.NODE_ENV === 'production' || process.env.PAYLOAD_MIGRATING === 'true') return;
|
46
46
|
// This will prompt if clarifications are needed for Drizzle to push new schema
|
47
47
|
const { apply, hasDataLoss, statementsToExecute, warnings } = await (0, _utils.pushSchema)(this.schema, this.drizzle);
|
48
|
-
// this.payload.logger.debug({
|
49
|
-
// hasDataLoss,
|
50
|
-
// msg: 'Schema push results',
|
51
|
-
// statementsToExecute,
|
52
|
-
// warnings,
|
53
|
-
// })
|
54
48
|
if (warnings.length) {
|
55
|
-
|
56
|
-
msg: `Warnings detected during schema push: ${warnings.join('\n')}`,
|
57
|
-
warnings
|
58
|
-
});
|
49
|
+
let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
|
59
50
|
if (hasDataLoss) {
|
60
|
-
|
61
|
-
msg: 'DATA LOSS WARNING: Possible data loss detected if schema is pushed.'
|
62
|
-
});
|
51
|
+
message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
|
63
52
|
}
|
53
|
+
message += `Accept warnings and push schema to database?`;
|
64
54
|
const { confirm: acceptWarnings } = await (0, _prompts.default)({
|
65
55
|
name: 'confirm',
|
66
56
|
initial: false,
|
67
|
-
message
|
57
|
+
message,
|
68
58
|
type: 'confirm'
|
69
59
|
}, {
|
70
60
|
onCancel: ()=>{
|
@@ -98,4 +88,4 @@ const connect = async function connect(payload) {
|
|
98
88
|
}
|
99
89
|
};
|
100
90
|
|
101
|
-
//# sourceMappingURL=data:application/json;base64,
|
91
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb25uZWN0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgQ29ubmVjdCB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB7IHB1c2hTY2hlbWEgfSBmcm9tICdkcml6emxlLWtpdC91dGlscydcbmltcG9ydCB7IGVxLCBzcWwgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB7IGRyaXp6bGUgfSBmcm9tICdkcml6emxlLW9ybS9ub2RlLXBvc3RncmVzJ1xuaW1wb3J0IHsgbnVtZXJpYywgcGdUYWJsZSwgdGltZXN0YW1wLCB2YXJjaGFyIH0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG9ydCB7IFBvb2wgfSBmcm9tICdwZydcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcydcblxuZXhwb3J0IGNvbnN0IGNvbm5lY3Q6IENvbm5lY3QgPSBhc3luYyBmdW5jdGlvbiBjb25uZWN0KHRoaXM6IFBvc3RncmVzQWRhcHRlciwgcGF5bG9hZCkge1xuICB0aGlzLnNjaGVtYSA9IHtcbiAgICAuLi50aGlzLnRhYmxlcyxcbiAgICAuLi50aGlzLnJlbGF0aW9ucyxcbiAgICAuLi50aGlzLmVudW1zLFxuICB9XG5cbiAg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E9BQU8sQ0FBQ3lDLE1BQU0sQ0FBQ2Isa0JBQWtCYyxNQUFNLENBQUM7WUFDakRsQixNQUFNO1lBQ05PLE9BQU87UUFDVDtJQUNGLE9BQU87UUFDTCxNQUFNLElBQUksQ0FBQy9CLE9BQU8sQ0FDZjJDLE1BQU0sQ0FBQ2Ysa0JBQ1BnQixHQUFHLENBQUM7WUFDSFQsWUFBWSxJQUFJVTtRQUNsQixHQUNDTixLQUFLLENBQUNDLElBQUFBLGNBQUUsRUFBQ1osaUJBQWlCRyxLQUFLLEVBQUU7SUFDdEM7QUFDRiJ9
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAoDvD,eAAO,MAAM,eAAe,EAAE,
|
1
|
+
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAoDvD,eAAO,MAAM,eAAe,EAAE,eA2E7B,CAAA"}
|
package/dist/createMigration.js
CHANGED
@@ -48,9 +48,6 @@ const getDefaultDrizzleSnapshot = ()=>({
|
|
48
48
|
version: '5'
|
49
49
|
});
|
50
50
|
const createMigration = async function createMigration(payload, migrationName) {
|
51
|
-
payload.logger.info({
|
52
|
-
msg: 'Creating new migration...'
|
53
|
-
});
|
54
51
|
const dir = payload.db.migrationDir;
|
55
52
|
if (!_fs.default.existsSync(dir)) {
|
56
53
|
_fs.default.mkdirSync(dir);
|
@@ -95,4 +92,4 @@ const createMigration = async function createMigration(payload, migrationName) {
|
|
95
92
|
});
|
96
93
|
};
|
97
94
|
|
98
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVNaWdyYXRpb24udHMiXSw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0FBRSxDQUFDMkMsYUFBYSxDQUNkLENBQUMsRUFBRTlCLFNBQVMsR0FBRyxDQUFDLEVBQ2hCL0Isa0JBQ0UrQyxnQkFBZ0JHLE1BQU0sR0FBR0gsaUJBQWlCZ0IsS0FBSyxRQUFRQyxXQUN2RGYsa0JBQWtCQyxNQUFNLEdBQUdELG1CQUFtQmMsS0FBSyxRQUFRQztJQUcvRG5ELFFBQVFvRCxNQUFNLENBQUNDLElBQUksQ0FBQztRQUFFQyxLQUFLLENBQUMscUJBQXFCLEVBQUVwQyxTQUFTLEdBQUcsQ0FBQztJQUFDO0FBQ25FIn0=
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAmB,qBAAqB,EAAE,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAmB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAmC3E,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7D,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,qBAAqB,CA0DjE"}
|
package/dist/index.js
CHANGED
@@ -29,6 +29,10 @@ const _findOne = require("./findOne");
|
|
29
29
|
const _findVersions = require("./findVersions");
|
30
30
|
const _init = require("./init");
|
31
31
|
const _migrate = require("./migrate");
|
32
|
+
const _migrateDown = require("./migrateDown");
|
33
|
+
const _migrateFresh = require("./migrateFresh");
|
34
|
+
const _migrateRefresh = require("./migrateRefresh");
|
35
|
+
const _migrateReset = require("./migrateReset");
|
32
36
|
const _migrateStatus = require("./migrateStatus");
|
33
37
|
const _queryDrafts = require("./queryDrafts");
|
34
38
|
const _beginTransaction = require("./transactions/beginTransaction");
|
@@ -49,12 +53,12 @@ function postgresAdapter(args) {
|
|
49
53
|
(0, _extendWebpackConfig.extendWebpackConfig)(payload.config);
|
50
54
|
(0, _extendViteConfig.extendViteConfig)(payload.config);
|
51
55
|
return (0, _database.createDatabaseAdapter)({
|
52
|
-
...args,
|
53
56
|
name: 'postgres',
|
54
57
|
// Postgres-specific
|
55
58
|
drizzle: undefined,
|
56
59
|
enums: {},
|
57
60
|
pool: undefined,
|
61
|
+
poolOptions: args.pool,
|
58
62
|
relations: {},
|
59
63
|
schema: {},
|
60
64
|
sessions: {},
|
@@ -80,6 +84,10 @@ function postgresAdapter(args) {
|
|
80
84
|
findVersions: _findVersions.findVersions,
|
81
85
|
init: _init.init,
|
82
86
|
migrate: _migrate.migrate,
|
87
|
+
migrateDown: _migrateDown.migrateDown,
|
88
|
+
migrateFresh: _migrateFresh.migrateFresh,
|
89
|
+
migrateRefresh: _migrateRefresh.migrateRefresh,
|
90
|
+
migrateReset: _migrateReset.migrateReset,
|
83
91
|
migrateStatus: _migrateStatus.migrateStatus,
|
84
92
|
migrationDir,
|
85
93
|
payload,
|
@@ -94,4 +102,4 @@ function postgresAdapter(args) {
|
|
94
102
|
return adapter;
|
95
103
|
}
|
96
104
|
|
97
|
-
//# sourceMappingURL=data:application/json;base64,
|
105
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuaW1wb3J0IHsgY3JlYXRlRGF0YWJhc2VBZGFwdGVyIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcblxuaW1wb3J0IHR5cGUgeyBBcmdzLCBQb3N0Z3Jlc0FkYXB0ZXIsIFBvc3RncmVzQWRhcHRlclJlc3VsdCB9IGZyb20gJy4vdHlwZXMnXG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sY0FBQUEsMEJBQVk7WUFDWkMsZ0JBQUFBLDhCQUFjO1lBQ2RDLGNBQUFBLDBCQUFZO1lBQ1pDLGVBQUFBLDRCQUFhO1lBQ2IzQztZQUNBRDtZQUNBNkMsYUFBQUEsd0JBQVc7WUFDWEMscUJBQUFBLHdDQUFtQjtZQUNuQkMsY0FBQUEsMEJBQVk7WUFDWkMscUJBQUFBLHdDQUFtQjtZQUNuQkMsV0FBQUEsaUJBQVM7WUFDVEMsZUFBQUEsNEJBQWE7UUFDZjtJQUNGO0lBRUEsT0FBT25EO0FBQ1QifQ==
|
package/dist/migrate.js
CHANGED
@@ -49,7 +49,7 @@ async function migrate() {
|
|
49
49
|
const { confirm: runMigrations } = await (0, _prompts.default)({
|
50
50
|
name: 'confirm',
|
51
51
|
initial: false,
|
52
|
-
message: "It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database
|
52
|
+
message: "It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database.\n\n" + "If you'd like to run migrations, data loss will occur. Would you like to proceed?",
|
53
53
|
type: 'confirm'
|
54
54
|
}, {
|
55
55
|
onCancel: ()=>{
|
@@ -107,4 +107,4 @@ async function runMigrationFile(payload, migration, batch) {
|
|
107
107
|
}
|
108
108
|
}
|
109
109
|
|
110
|
-
//# sourceMappingURL=data:application/json;base64,
|
110
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXJlc3RyaWN0ZWQtc3ludGF4LCBuby1hd2FpdC1pbi1sb29wICovXG5pbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBNaWdyYXRpb24gfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgeyBnZW5lcmF0ZURyaXp6bGV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TUFBTXlDO0lBQ1I7QUFDRiJ9
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA2DtE"}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/* eslint-disable no-restricted-syntax, no-await-in-loop */ "use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "migrateDown", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return migrateDown;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _database = require("payload/database");
|
12
|
+
const _migrationTableExists = require("./utilities/migrationTableExists");
|
13
|
+
async function migrateDown() {
|
14
|
+
const { payload } = this;
|
15
|
+
const migrationFiles = await (0, _database.readMigrationFiles)({
|
16
|
+
payload
|
17
|
+
});
|
18
|
+
const { existingMigrations, latestBatch } = await (0, _database.getMigrations)({
|
19
|
+
payload
|
20
|
+
});
|
21
|
+
const migrationsToRollback = existingMigrations.filter((migration)=>migration.batch === latestBatch && migration.batch !== -1);
|
22
|
+
if (!migrationsToRollback?.length) {
|
23
|
+
payload.logger.info({
|
24
|
+
msg: 'No migrations to rollback.'
|
25
|
+
});
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
payload.logger.info({
|
29
|
+
msg: `Rolling back batch ${latestBatch} consisting of ${migrationsToRollback.length} migration(s).`
|
30
|
+
});
|
31
|
+
for (const migration of migrationsToRollback){
|
32
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
33
|
+
if (!migrationFile) {
|
34
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
35
|
+
}
|
36
|
+
const start = Date.now();
|
37
|
+
let transactionID;
|
38
|
+
try {
|
39
|
+
payload.logger.info({
|
40
|
+
msg: `Migrating down: ${migrationFile.name}`
|
41
|
+
});
|
42
|
+
transactionID = await this.beginTransaction();
|
43
|
+
await migrationFile.down({
|
44
|
+
payload
|
45
|
+
});
|
46
|
+
payload.logger.info({
|
47
|
+
msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`
|
48
|
+
});
|
49
|
+
const tableExists = await (0, _migrationTableExists.migrationTableExists)(this.drizzle);
|
50
|
+
if (tableExists) {
|
51
|
+
await payload.delete({
|
52
|
+
id: migration.id,
|
53
|
+
collection: 'payload-migrations',
|
54
|
+
req: {
|
55
|
+
transactionID
|
56
|
+
}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
await this.commitTransaction(transactionID);
|
60
|
+
} catch (err) {
|
61
|
+
await this.rollbackTransaction(transactionID);
|
62
|
+
payload.logger.error({
|
63
|
+
err,
|
64
|
+
msg: `Error running migration ${migrationFile.name}`
|
65
|
+
});
|
66
|
+
throw err;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlRG93bi50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tYXdhaXQtaW4tbG9vcCAqL1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGdldE1pZ3JhdGlvbnMsIHJlYWRNaWdyYXRpb25GaWxlcyB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcydcblxuaW1wb3J0IHsgbWlncmF0aW9uVGFibGVFeGlzdHMgfSBmcm9tIC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"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "migrateFresh", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return migrateFresh;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _drizzleorm = require("drizzle-orm");
|
12
|
+
const _database = require("payload/database");
|
13
|
+
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
|
14
|
+
function _interop_require_default(obj) {
|
15
|
+
return obj && obj.__esModule ? obj : {
|
16
|
+
default: obj
|
17
|
+
};
|
18
|
+
}
|
19
|
+
async function migrateFresh() {
|
20
|
+
const { payload } = this;
|
21
|
+
const { confirm: acceptWarning } = await (0, _prompts.default)({
|
22
|
+
name: 'confirm',
|
23
|
+
initial: false,
|
24
|
+
message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`,
|
25
|
+
type: 'confirm'
|
26
|
+
}, {
|
27
|
+
onCancel: ()=>{
|
28
|
+
process.exit(0);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
if (!acceptWarning) {
|
32
|
+
process.exit(0);
|
33
|
+
}
|
34
|
+
payload.logger.info({
|
35
|
+
msg: `Dropping database.`
|
36
|
+
});
|
37
|
+
await this.drizzle.execute((0, _drizzleorm.sql)`drop schema public cascade;\ncreate schema public;`);
|
38
|
+
const migrationFiles = await (0, _database.readMigrationFiles)({
|
39
|
+
payload
|
40
|
+
});
|
41
|
+
payload.logger.debug({
|
42
|
+
msg: `Found ${migrationFiles.length} migration files.`
|
43
|
+
});
|
44
|
+
let transactionID;
|
45
|
+
// Run all migrate up
|
46
|
+
for (const migration of migrationFiles){
|
47
|
+
payload.logger.info({
|
48
|
+
msg: `Migrating: ${migration.name}`
|
49
|
+
});
|
50
|
+
try {
|
51
|
+
const start = Date.now();
|
52
|
+
transactionID = await this.beginTransaction();
|
53
|
+
await migration.up({
|
54
|
+
payload
|
55
|
+
});
|
56
|
+
await payload.create({
|
57
|
+
collection: 'payload-migrations',
|
58
|
+
data: {
|
59
|
+
name: migration.name,
|
60
|
+
batch: 1
|
61
|
+
},
|
62
|
+
req: {
|
63
|
+
transactionID
|
64
|
+
}
|
65
|
+
});
|
66
|
+
await this.commitTransaction(transactionID);
|
67
|
+
payload.logger.info({
|
68
|
+
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
69
|
+
});
|
70
|
+
} catch (err) {
|
71
|
+
await this.rollbackTransaction(transactionID);
|
72
|
+
payload.logger.error({
|
73
|
+
err,
|
74
|
+
msg: `Error running migration ${migration.name}. Rolling back.`
|
75
|
+
});
|
76
|
+
throw err;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlRnJlc2gudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IHNxbCB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHsgcmVhZE1pZ3JhdGlvbkZpbGVzIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcydcblxuLyoqXG4gKiBEcm9wIHRoZSBjdXJyZW50IGRhdGFiYXNlIGFuZCBydW4gYWxsIG1pZ3JhdGUgdXAgZnVuY3Rpb25zXG4gKi9cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBtaWdyYXRlRnJlc2godGhpczogUG9zdGdyZXNBZGFwdGVyKTogUHJvbWlzZTx2b2lkPiB7XG4gIGNvbnN0IHsgcGF5bG9hZCB9ID0gdGhpc1xuXG4gIGNvbn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ixFQUFFLE9BQU9XLEtBQWM7WUFDckIsTUFBTSxJQUFJLENBQUNDLG1CQUFtQixDQUFDZDtZQUMvQnJCLFFBQVFXLE1BQU0sQ0FBQ3lCLEtBQUssQ0FBQztnQkFDbkJGO2dCQUNBckIsS0FBSyxDQUFDLHdCQUF3QixFQUFFUyxVQUFVbEIsSUFBSSxDQUFDLGVBQWUsQ0FBQztZQUNqRTtZQUNBLE1BQU04QjtRQUNSO0lBQ0Y7QUFDRiJ9
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,iBAkGzD"}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
/* eslint-disable no-restricted-syntax, no-await-in-loop */ "use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "migrateRefresh", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return migrateRefresh;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _database = require("payload/database");
|
12
|
+
const _migrationTableExists = require("./utilities/migrationTableExists");
|
13
|
+
async function migrateRefresh() {
|
14
|
+
const { payload } = this;
|
15
|
+
const migrationFiles = await (0, _database.readMigrationFiles)({
|
16
|
+
payload
|
17
|
+
});
|
18
|
+
const { existingMigrations, latestBatch } = await (0, _database.getMigrations)({
|
19
|
+
payload
|
20
|
+
});
|
21
|
+
const migrationsToRollback = existingMigrations.filter((migration)=>migration.batch === latestBatch && migration.batch !== -1);
|
22
|
+
if (!migrationsToRollback?.length) {
|
23
|
+
payload.logger.info({
|
24
|
+
msg: 'No migrations to rollback.'
|
25
|
+
});
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
payload.logger.info({
|
29
|
+
msg: `Rolling back batch ${latestBatch} consisting of ${migrationsToRollback.length} migration(s).`
|
30
|
+
});
|
31
|
+
let transactionID;
|
32
|
+
// Reverse order of migrations to rollback
|
33
|
+
migrationsToRollback.reverse();
|
34
|
+
for (const migration of migrationsToRollback){
|
35
|
+
try {
|
36
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
37
|
+
if (!migrationFile) {
|
38
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
39
|
+
}
|
40
|
+
payload.logger.info({
|
41
|
+
msg: `Migrating down: ${migration.name}`
|
42
|
+
});
|
43
|
+
const start = Date.now();
|
44
|
+
transactionID = await this.beginTransaction();
|
45
|
+
await migrationFile.down({
|
46
|
+
payload
|
47
|
+
});
|
48
|
+
payload.logger.info({
|
49
|
+
msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`
|
50
|
+
});
|
51
|
+
const tableExists = await (0, _migrationTableExists.migrationTableExists)(this.drizzle);
|
52
|
+
if (tableExists) {
|
53
|
+
await payload.delete({
|
54
|
+
collection: 'payload-migrations',
|
55
|
+
req: {
|
56
|
+
transactionID
|
57
|
+
},
|
58
|
+
where: {
|
59
|
+
name: {
|
60
|
+
equals: migration.name
|
61
|
+
}
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
} catch (err) {
|
66
|
+
await this.rollbackTransaction(transactionID);
|
67
|
+
let msg = `Error running migration ${migration.name}. Rolling back.`;
|
68
|
+
if (err instanceof Error) {
|
69
|
+
msg += ` ${err.message}`;
|
70
|
+
}
|
71
|
+
payload.logger.error({
|
72
|
+
err,
|
73
|
+
msg
|
74
|
+
});
|
75
|
+
throw err;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
// Run all migrate up
|
79
|
+
for (const migration of migrationFiles){
|
80
|
+
payload.logger.info({
|
81
|
+
msg: `Migrating: ${migration.name}`
|
82
|
+
});
|
83
|
+
try {
|
84
|
+
const start = Date.now();
|
85
|
+
transactionID = await this.beginTransaction();
|
86
|
+
await migration.up({
|
87
|
+
payload
|
88
|
+
});
|
89
|
+
await payload.create({
|
90
|
+
collection: 'payload-migrations',
|
91
|
+
data: {
|
92
|
+
name: migration.name,
|
93
|
+
executed: true
|
94
|
+
},
|
95
|
+
req: {
|
96
|
+
transactionID
|
97
|
+
}
|
98
|
+
});
|
99
|
+
await this.commitTransaction(transactionID);
|
100
|
+
payload.logger.info({
|
101
|
+
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
102
|
+
});
|
103
|
+
} catch (err) {
|
104
|
+
await this.rollbackTransaction(transactionID);
|
105
|
+
payload.logger.error({
|
106
|
+
err,
|
107
|
+
msg: `Error running migration ${migration.name}. Rolling back.`
|
108
|
+
});
|
109
|
+
throw err;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlUmVmcmVzaC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tYXdhaXQtaW4tbG9vcCAqL1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGdldE1pZ3JhdGlvbnMsIHJlYWRNaWdyYXRpb25GaWxlcyB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcydcblxuaW1wb3J0IHsgbWlncmF0aW9uVGFibGVFeGlzdHMgfSBmcm9tICcuL3V0aWxpdGllcy9taWdyYXRpb25UYWJsZUV4aXN0cydcblxuLyoqXG4gKiBSdW4gYWxsIG1pZ3JhdGlvbiBkb3duIGZ1bmN0aW9ucyBiZWZvcmUgcnVubmluZyB1cFxuIC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ZQUFDO1FBQ3RGLEVBQUUsT0FBT2EsS0FBYztZQUNyQixNQUFNLElBQUksQ0FBQ0MsbUJBQW1CLENBQUNyQjtZQUMvQmQsUUFBUVcsTUFBTSxDQUFDMEIsS0FBSyxDQUFDO2dCQUNuQkg7Z0JBQ0FyQixLQUFLLENBQUMsd0JBQXdCLEVBQUVMLFVBQVVXLElBQUksQ0FBQyxlQUFlLENBQUM7WUFDakU7WUFDQSxNQUFNZTtRQUNSO0lBQ0Y7QUFDRiJ9
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEvE"}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/* eslint-disable no-restricted-syntax, no-await-in-loop */ "use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "migrateReset", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return migrateReset;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _database = require("payload/database");
|
12
|
+
const _migrationTableExists = require("./utilities/migrationTableExists");
|
13
|
+
async function migrateReset() {
|
14
|
+
const { payload } = this;
|
15
|
+
const migrationFiles = await (0, _database.readMigrationFiles)({
|
16
|
+
payload
|
17
|
+
});
|
18
|
+
const { existingMigrations } = await (0, _database.getMigrations)({
|
19
|
+
payload
|
20
|
+
});
|
21
|
+
if (!existingMigrations?.length) {
|
22
|
+
payload.logger.info({
|
23
|
+
msg: 'No migrations to reset.'
|
24
|
+
});
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
// Rollback all migrations in order
|
28
|
+
for (const migration of existingMigrations){
|
29
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
30
|
+
if (!migrationFile) {
|
31
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
32
|
+
}
|
33
|
+
const start = Date.now();
|
34
|
+
let transactionID;
|
35
|
+
try {
|
36
|
+
payload.logger.info({
|
37
|
+
msg: `Migrating down: ${migrationFile.name}`
|
38
|
+
});
|
39
|
+
transactionID = await this.beginTransaction();
|
40
|
+
await migrationFile.down({
|
41
|
+
payload
|
42
|
+
});
|
43
|
+
payload.logger.info({
|
44
|
+
msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`
|
45
|
+
});
|
46
|
+
const tableExists = await (0, _migrationTableExists.migrationTableExists)(this.drizzle);
|
47
|
+
if (tableExists) {
|
48
|
+
await payload.delete({
|
49
|
+
id: migration.id,
|
50
|
+
collection: 'payload-migrations',
|
51
|
+
req: {
|
52
|
+
transactionID
|
53
|
+
}
|
54
|
+
});
|
55
|
+
}
|
56
|
+
await this.commitTransaction(transactionID);
|
57
|
+
} catch (err) {
|
58
|
+
await this.rollbackTransaction(transactionID);
|
59
|
+
payload.logger.error({
|
60
|
+
err,
|
61
|
+
msg: `Error running migration ${migrationFile.name}`
|
62
|
+
});
|
63
|
+
throw err;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
// Delete dev migration
|
67
|
+
const tableExists = await (0, _migrationTableExists.migrationTableExists)(this.drizzle);
|
68
|
+
if (tableExists) {
|
69
|
+
try {
|
70
|
+
await payload.delete({
|
71
|
+
collection: 'payload-migrations',
|
72
|
+
where: {
|
73
|
+
batch: {
|
74
|
+
equals: -1
|
75
|
+
}
|
76
|
+
}
|
77
|
+
});
|
78
|
+
} catch (err) {
|
79
|
+
payload.logger.error({
|
80
|
+
error: err,
|
81
|
+
msg: 'Error deleting dev migration'
|
82
|
+
});
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2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FDQXJCLEtBQUssQ0FBQyx3QkFBd0IsRUFBRUUsY0FBY0csSUFBSSxDQUFDLENBQUM7WUFDdEQ7WUFDQSxNQUFNZ0I7UUFDUjtJQUNGO0lBRUEsdUJBQXVCO0lBRXZCLE1BQU1SLGNBQWMsTUFBTUMsSUFBQUEsMENBQW9CLEVBQUMsSUFBSSxDQUFDQyxPQUFPO0lBQzNELElBQUlGLGFBQWE7UUFDZixJQUFJO1lBQ0YsTUFBTXJCLFFBQVF3QixNQUFNLENBQUM7Z0JBQ25CRSxZQUFZO2dCQUNaTSxPQUFPO29CQUNMQyxPQUFPO3dCQUNMQyxRQUFRLENBQUM7b0JBQ1g7Z0JBQ0Y7WUFDRjtRQUNGLEVBQUUsT0FBT0wsS0FBYztZQUNyQjdCLFFBQVFNLE1BQU0sQ0FBQ3lCLEtBQUssQ0FBQztnQkFBRUEsT0FBT0Y7Z0JBQUtyQixLQUFLO1lBQStCO1FBQ3pFO0lBQ0Y7QUFDRiJ9
|
package/dist/types.d.ts
CHANGED
@@ -6,9 +6,8 @@ import type { BaseDatabaseAdapter } from 'payload/database';
|
|
6
6
|
import type { Pool, PoolConfig } from 'pg';
|
7
7
|
export type DrizzleDB = NodePgDatabase<Record<string, unknown>>;
|
8
8
|
export type Args = {
|
9
|
-
client: PoolConfig;
|
10
9
|
migrationDir?: string;
|
11
|
-
|
10
|
+
pool: PoolConfig;
|
12
11
|
};
|
13
12
|
export type GenericColumn = PgColumn<ColumnBaseConfig<ColumnDataType, string>, Record<string, unknown>>;
|
14
13
|
export type GenericColumns = {
|
@@ -23,10 +22,11 @@ export type GenericTable = PgTableWithColumns<{
|
|
23
22
|
export type GenericEnum = PgEnum<[string, ...string[]]>;
|
24
23
|
export type GenericRelation = Relations<string, Record<string, Relation<string>>>;
|
25
24
|
export type DrizzleTransaction = PgTransaction<NodePgQueryResultHKT, Record<string, unknown>, ExtractTablesWithRelations<Record<string, unknown>>>;
|
26
|
-
export type PostgresAdapter = BaseDatabaseAdapter &
|
25
|
+
export type PostgresAdapter = BaseDatabaseAdapter & {
|
27
26
|
drizzle: DrizzleDB;
|
28
27
|
enums: Record<string, GenericEnum>;
|
29
28
|
pool: Pool;
|
29
|
+
poolOptions: Args['pool'];
|
30
30
|
relations: Record<string, GenericRelation>;
|
31
31
|
schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
|
32
32
|
sessions: {
|
@@ -48,7 +48,7 @@ export type MigrateDownArgs = {
|
|
48
48
|
payload: Payload;
|
49
49
|
};
|
50
50
|
declare module 'payload' {
|
51
|
-
interface DatabaseAdapter extends Args {
|
51
|
+
interface DatabaseAdapter extends Omit<Args, 'pool'> {
|
52
52
|
drizzle: DrizzleDB;
|
53
53
|
enums: Record<string, GenericEnum>;
|
54
54
|
pool: Pool;
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAE1C,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D,MAAM,MAAM,IAAI,GAAG;IACjB,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts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EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAClC,IAAI,EAAE,IAAI,CAAA;QACV,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;QAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,GAAG,YAAY,CAAC,CAAA;QACpE,QAAQ,EAAE;YACR,CAAC,EAAE,EAAE,MAAM,GAAG;gBACZ,EAAE,EAAE,kBAAkB,CAAA;gBACtB,MAAM,EAAE,MAAM,IAAI,CAAA;gBAClB,OAAO,EAAE,MAAM,IAAI,CAAA;aACpB,CAAA;SACF,CAAA;QACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;KACrC;CACF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "0.1.0-beta.
|
3
|
+
"version": "0.1.0-beta.16",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
6
6
|
"license": "MIT",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"@types/pg": "8.10.2",
|
26
26
|
"@types/to-snake-case": "1.0.0",
|
27
27
|
"@payloadcms/eslint-config": "0.0.1",
|
28
|
-
"payload": "2.0.0-beta.
|
28
|
+
"payload": "2.0.0-beta.26"
|
29
29
|
},
|
30
30
|
"peerDependencies": {
|
31
31
|
"better-sqlite3": "^8.5.0"
|
package/src/index.ts
CHANGED
@@ -5,8 +5,6 @@ import { createDatabaseAdapter } from 'payload/database'
|
|
5
5
|
|
6
6
|
import type { Args, PostgresAdapter, PostgresAdapterResult } from './types'
|
7
7
|
|
8
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types'
|
9
|
-
|
10
8
|
import { connect } from './connect'
|
11
9
|
import { create } from './create'
|
12
10
|
import { createGlobal } from './createGlobal'
|
@@ -26,6 +24,10 @@ import { findOne } from './findOne'
|
|
26
24
|
import { findVersions } from './findVersions'
|
27
25
|
import { init } from './init'
|
28
26
|
import { migrate } from './migrate'
|
27
|
+
import { migrateDown } from './migrateDown'
|
28
|
+
import { migrateFresh } from './migrateFresh'
|
29
|
+
import { migrateRefresh } from './migrateRefresh'
|
30
|
+
import { migrateReset } from './migrateReset'
|
29
31
|
import { migrateStatus } from './migrateStatus'
|
30
32
|
import { queryDrafts } from './queryDrafts'
|
31
33
|
import { beginTransaction } from './transactions/beginTransaction'
|
@@ -36,6 +38,8 @@ import { updateGlobal } from './updateGlobal'
|
|
36
38
|
import { updateGlobalVersion } from './updateGlobalVersion'
|
37
39
|
import { updateVersion } from './updateVersion'
|
38
40
|
|
41
|
+
export type { MigrateDownArgs, MigrateUpArgs } from './types'
|
42
|
+
|
39
43
|
export function postgresAdapter(args: Args): PostgresAdapterResult {
|
40
44
|
function adapter({ payload }: { payload: Payload }) {
|
41
45
|
const migrationDir = args.migrationDir || path.resolve(process.cwd(), 'src/migrations')
|
@@ -44,13 +48,13 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
|
|
44
48
|
extendViteConfig(payload.config)
|
45
49
|
|
46
50
|
return createDatabaseAdapter<PostgresAdapter>({
|
47
|
-
...args,
|
48
51
|
name: 'postgres',
|
49
52
|
|
50
53
|
// Postgres-specific
|
51
54
|
drizzle: undefined,
|
52
55
|
enums: {},
|
53
56
|
pool: undefined,
|
57
|
+
poolOptions: args.pool,
|
54
58
|
relations: {},
|
55
59
|
schema: {},
|
56
60
|
sessions: {},
|
@@ -77,6 +81,10 @@ export function postgresAdapter(args: Args): PostgresAdapterResult {
|
|
77
81
|
findVersions,
|
78
82
|
init,
|
79
83
|
migrate,
|
84
|
+
migrateDown,
|
85
|
+
migrateFresh,
|
86
|
+
migrateRefresh,
|
87
|
+
migrateReset,
|
80
88
|
migrateStatus,
|
81
89
|
migrationDir,
|
82
90
|
payload,
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import type { Payload } from 'payload';
|
2
|
-
import type { Migration } from 'payload/database';
|
3
|
-
type RunMigrationArgs = {
|
4
|
-
batch: number;
|
5
|
-
migration: Migration;
|
6
|
-
payload: Payload;
|
7
|
-
};
|
8
|
-
export declare function runUp({ batch, migration, payload }: RunMigrationArgs): Promise<void>;
|
9
|
-
type RunMigrationDownArgs = {
|
10
|
-
migration: Migration;
|
11
|
-
payload: Payload;
|
12
|
-
};
|
13
|
-
export declare function runDown({ migration, payload }: RunMigrationDownArgs): Promise<void>;
|
14
|
-
export {};
|
15
|
-
//# sourceMappingURL=migrations.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/utilities/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAKjD,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wBAAsB,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,gBAAgB,iBA0B1E;AAED,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wBAAsB,OAAO,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,oBAAoB,iBA4BzE"}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
7
|
-
enumerable: true,
|
8
|
-
get: all[name]
|
9
|
-
});
|
10
|
-
}
|
11
|
-
_export(exports, {
|
12
|
-
runUp: function() {
|
13
|
-
return runUp;
|
14
|
-
},
|
15
|
-
runDown: function() {
|
16
|
-
return runDown;
|
17
|
-
}
|
18
|
-
});
|
19
|
-
const _pg = require("pg");
|
20
|
-
async function runUp({ batch, migration, payload }) {
|
21
|
-
const start = Date.now();
|
22
|
-
payload.logger.info({
|
23
|
-
msg: `Migrating: ${migration.name}`
|
24
|
-
});
|
25
|
-
try {
|
26
|
-
await migration.up({
|
27
|
-
payload
|
28
|
-
});
|
29
|
-
payload.logger.info({
|
30
|
-
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
31
|
-
});
|
32
|
-
await payload.create({
|
33
|
-
collection: 'payload-migrations',
|
34
|
-
data: {
|
35
|
-
name: migration.name,
|
36
|
-
batch
|
37
|
-
}
|
38
|
-
});
|
39
|
-
} catch (err) {
|
40
|
-
let msg = `Error running migration ${migration.name}`;
|
41
|
-
if (err instanceof _pg.DatabaseError) {
|
42
|
-
msg += `: ${err.message}`;
|
43
|
-
if (err.hint) msg += `. ${err.hint}`;
|
44
|
-
}
|
45
|
-
payload.logger.error({
|
46
|
-
err,
|
47
|
-
msg
|
48
|
-
});
|
49
|
-
throw err;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
async function runDown({ migration, payload }) {
|
53
|
-
const start = Date.now();
|
54
|
-
let transactionID;
|
55
|
-
try {
|
56
|
-
payload.logger.info({
|
57
|
-
msg: `Migrating down: ${migration.name}`
|
58
|
-
});
|
59
|
-
transactionID = await this.beginTransaction();
|
60
|
-
await migration.down({
|
61
|
-
payload
|
62
|
-
});
|
63
|
-
payload.logger.info({
|
64
|
-
msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`
|
65
|
-
});
|
66
|
-
// Waiting for implementation here
|
67
|
-
await payload.delete({
|
68
|
-
id: migration.id,
|
69
|
-
collection: 'payload-migrations',
|
70
|
-
req: {
|
71
|
-
transactionID
|
72
|
-
}
|
73
|
-
});
|
74
|
-
await this.commitTransaction(transactionID);
|
75
|
-
} catch (err) {
|
76
|
-
await this.rollbackTransaction(transactionID);
|
77
|
-
payload.logger.error({
|
78
|
-
err,
|
79
|
-
msg: `Error running migration ${migration.name}`
|
80
|
-
});
|
81
|
-
throw err;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvbWlncmF0aW9ucy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBNaWdyYXRpb24gfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IERhdGFiYXNlRXJyb3IgfSBmcm9tICdwZydcblxudHlwZSBSdW5NaWdyYXRpb25BcmdzID0ge1xuICBiYXRjaDogbnVtYmVyXG4gIG1pZ3JhdGlvbjogTWlncmF0aW9uXG4gIHBheWxvYWQ6IFBheWxvYWRcbn1cblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHJ1blVwKHsgYmF0Y2gsIG1pZ3JhdGlvbiwgcGF5bG9hZCB9OiBSdW5NaWdyYXRpb25BcmdzKSB7XG4gIGNvbnN0IHN0YXJ0ID0gRGF0ZS5ub3coKVxuXG4gIHBheWxvYWQubG9nZ2VyLmluZm8oeyBtc2c6IGBNaWdyYXRpbmc6ICR7bWlncmF0aW9uLm5hbWV9YCB9KVxuXG4gIHRyeSB7XG4gICAgYXdhaXQgbWlncmF0aW9uLnVwKHsgcGF5bG9hZCB9KVxuICAgIHBheWxvYWQubG9nZ2VyLmluZm8oeyBtc2c6IGBNaWdyYXRlZDogICR7bWlncmF0aW9uLm5hbWV9ICgke0RhdGUubm93KCkgLSBzdGFydH1tcylgIH0pXG4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