@payloadcms/db-postgres 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +12 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +7 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +14 -5
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +13 -10
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +15 -12
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +17 -15
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +11 -9
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +29 -5
- package/dist/schema/build.d.ts +3 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +58 -17
- package/dist/schema/getConfigIDType.d.ts +3 -0
- package/dist/schema/getConfigIDType.d.ts.map +1 -0
- package/dist/schema/getConfigIDType.js +25 -0
- package/dist/schema/traverseFields.d.ts +4 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +48 -8
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +49 -7
- package/dist/transform/read/hasManyText.d.ts +10 -0
- package/dist/transform/read/hasManyText.d.ts.map +1 -0
- package/dist/transform/read/hasManyText.js +20 -0
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +7 -1
- package/dist/transform/read/traverseFields.d.ts +5 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +53 -2
- package/dist/transform/write/array.d.ts +2 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +3 -2
- package/dist/transform/write/blocks.d.ts +2 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +3 -2
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +3 -1
- package/dist/transform/write/texts.d.ts +8 -0
- package/dist/transform/write/texts.d.ts.map +1 -0
- package/dist/transform/write/texts.js +21 -0
- package/dist/transform/write/traverseFields.d.ts +2 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +41 -2
- package/dist/transform/write/types.d.ts +1 -0
- package/dist/transform/write/types.d.ts.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +28 -1
- package/package.json +3 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildFindManyArgs.d.ts","sourceRoot":"","sources":["../../src/find/buildFindManyArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAI1D,eAAO,MAAM,iBAAiB,2CAK3B,kBAAkB,KAAG,OAAO,MAAM,EAAE,OAAO,
|
1
|
+
{"version":3,"file":"buildFindManyArgs.d.ts","sourceRoot":"","sources":["../../src/find/buildFindManyArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAI1D,eAAO,MAAM,iBAAiB,2CAK3B,kBAAkB,KAAG,OAAO,MAAM,EAAE,OAAO,CA2D7C,CAAA"}
|
@@ -19,6 +19,17 @@ const buildFindManyArgs = ({ adapter, depth, fields, tableName })=>{
|
|
19
19
|
_parentID: false
|
20
20
|
}
|
21
21
|
};
|
22
|
+
if (adapter.tables[`${tableName}_texts`]) {
|
23
|
+
result.with._texts = {
|
24
|
+
columns: {
|
25
|
+
id: false,
|
26
|
+
parent: false
|
27
|
+
},
|
28
|
+
orderBy: ({ order }, { asc: ASC })=>[
|
29
|
+
ASC(order)
|
30
|
+
]
|
31
|
+
};
|
32
|
+
}
|
22
33
|
if (adapter.tables[`${tableName}_numbers`]) {
|
23
34
|
result.with._numbers = {
|
24
35
|
columns: {
|
@@ -58,4 +69,4 @@ const buildFindManyArgs = ({ adapter, depth, fields, tableName })=>{
|
|
58
69
|
return result;
|
59
70
|
};
|
60
71
|
|
61
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maW5kL2J1aWxkRmluZE1hbnlBcmdzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgREJRdWVyeUNvbmZpZyB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHR5cGUgeyBGaWVsZCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMnX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BSTtnQkFDSkksUUFBUTtZQUNWO1lBQ0FDLFNBQVMsQ0FBQyxFQUFFQyxLQUFLLEVBQUUsRUFBRSxFQUFFQyxLQUFLQyxHQUFHLEVBQUUsR0FBSztvQkFBQ0EsSUFBSUY7aUJBQU87UUFDcEQ7SUFDRjtJQUVBLElBQUlkLFFBQVFVLE1BQU0sQ0FBQyxDQUFDLEVBQUVQLFVBQVUsUUFBUSxDQUFDLENBQUMsRUFBRTtRQUMxQ0MsT0FBT0MsSUFBSSxDQUFDQyxRQUFRLEdBQUdBO0lBQ3pCO0lBRUFhLElBQUFBLDhCQUFjLEVBQUM7UUFDYmI7UUFDQU47UUFDQW9CLGFBQWFoQjtRQUNiaUIsa0JBQWtCbEI7UUFDbEJGO1FBQ0FDO1FBQ0FvQixNQUFNO1FBQ05DLGNBQWNuQjtRQUNkb0IsbUJBQW1CckI7SUFDckI7SUFFQSxPQUFPQztBQUNUIn0=
|
package/dist/init.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAY5C,eAAO,MAAM,IAAI,EAAE,IA2ElB,CAAA"}
|
package/dist/init.js
CHANGED
@@ -12,6 +12,7 @@ const _pgcore = require("drizzle-orm/pg-core");
|
|
12
12
|
const _versions = require("payload/versions");
|
13
13
|
const _tosnakecase = /*#__PURE__*/ _interop_require_default(require("to-snake-case"));
|
14
14
|
const _build = require("./schema/build");
|
15
|
+
const _getConfigIDType = require("./schema/getConfigIDType");
|
15
16
|
function _interop_require_default(obj) {
|
16
17
|
return obj && obj.__esModule ? obj : {
|
17
18
|
default: obj
|
@@ -25,6 +26,7 @@ const init = async function init() {
|
|
25
26
|
const tableName = (0, _tosnakecase.default)(collection.slug);
|
26
27
|
(0, _build.buildTable)({
|
27
28
|
adapter: this,
|
29
|
+
buildTexts: true,
|
28
30
|
buildNumbers: true,
|
29
31
|
buildRelationships: true,
|
30
32
|
disableNotNull: !!collection?.versions?.drafts,
|
@@ -36,8 +38,10 @@ const init = async function init() {
|
|
36
38
|
if (collection.versions) {
|
37
39
|
const versionsTableName = `_${tableName}_v`;
|
38
40
|
const versionFields = (0, _versions.buildVersionCollectionFields)(collection);
|
41
|
+
const versionsParentIDColType = (0, _getConfigIDType.getConfigIDType)(collection.fields);
|
39
42
|
(0, _build.buildTable)({
|
40
43
|
adapter: this,
|
44
|
+
buildTexts: true,
|
41
45
|
buildNumbers: true,
|
42
46
|
buildRelationships: true,
|
43
47
|
disableNotNull: !!collection.versions?.drafts,
|
@@ -52,6 +56,7 @@ const init = async function init() {
|
|
52
56
|
const tableName = (0, _tosnakecase.default)(global.slug);
|
53
57
|
(0, _build.buildTable)({
|
54
58
|
adapter: this,
|
59
|
+
buildTexts: true,
|
55
60
|
buildNumbers: true,
|
56
61
|
buildRelationships: true,
|
57
62
|
disableNotNull: !!global?.versions?.drafts,
|
@@ -65,6 +70,7 @@ const init = async function init() {
|
|
65
70
|
const versionFields = (0, _versions.buildVersionGlobalFields)(global);
|
66
71
|
(0, _build.buildTable)({
|
67
72
|
adapter: this,
|
73
|
+
buildTexts: true,
|
68
74
|
buildNumbers: true,
|
69
75
|
buildRelationships: true,
|
70
76
|
disableNotNull: !!global.versions?.drafts,
|
@@ -77,4 +83,4 @@ const init = async function init() {
|
|
77
83
|
});
|
78
84
|
};
|
79
85
|
|
80
|
-
//# sourceMappingURL=data:application/json;base64,
|
86
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbml0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vL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[],"mappings":"
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM9C,wBAAsB,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DlE"}
|
package/dist/migrate.js
CHANGED
@@ -9,6 +9,9 @@ Object.defineProperty(exports, "migrate", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _database = require("payload/database");
|
12
|
+
const _commitTransaction = require("payload/dist/utilities/commitTransaction");
|
13
|
+
const _initTransaction = require("payload/dist/utilities/initTransaction");
|
14
|
+
const _killTransaction = require("payload/dist/utilities/killTransaction");
|
12
15
|
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
|
13
16
|
const _createMigrationTable = require("./utilities/createMigrationTable");
|
14
17
|
const _migrationTableExists = require("./utilities/migrationTableExists");
|
@@ -47,9 +50,9 @@ async function migrate() {
|
|
47
50
|
if (migrationsInDB.find((m)=>m.batch === -1)) {
|
48
51
|
const { confirm: runMigrations } = await (0, _prompts.default)({
|
49
52
|
name: 'confirm',
|
53
|
+
type: 'confirm',
|
50
54
|
initial: false,
|
51
|
-
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?"
|
52
|
-
type: 'confirm'
|
55
|
+
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
56
|
}, {
|
54
57
|
onCancel: ()=>{
|
55
58
|
process.exit(0);
|
@@ -73,14 +76,17 @@ async function migrate() {
|
|
73
76
|
async function runMigrationFile(payload, migration, batch) {
|
74
77
|
const { generateDrizzleJson } = require('drizzle-kit/utils');
|
75
78
|
const start = Date.now();
|
79
|
+
const req = {};
|
76
80
|
payload.logger.info({
|
77
81
|
msg: `Migrating: ${migration.name}`
|
78
82
|
});
|
79
83
|
const pgAdapter = payload.db;
|
80
84
|
const drizzleJSON = generateDrizzleJson(pgAdapter.schema);
|
81
85
|
try {
|
86
|
+
await (0, _initTransaction.initTransaction)(req);
|
82
87
|
await migration.up({
|
83
|
-
payload
|
88
|
+
payload,
|
89
|
+
req
|
84
90
|
});
|
85
91
|
payload.logger.info({
|
86
92
|
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
@@ -91,9 +97,12 @@ async function runMigrationFile(payload, migration, batch) {
|
|
91
97
|
name: migration.name,
|
92
98
|
batch,
|
93
99
|
schema: drizzleJSON
|
94
|
-
}
|
100
|
+
},
|
101
|
+
req
|
95
102
|
});
|
103
|
+
await (0, _commitTransaction.commitTransaction)(req);
|
96
104
|
} catch (err) {
|
105
|
+
await (0, _killTransaction.killTransaction)(req);
|
97
106
|
payload.logger.error({
|
98
107
|
err,
|
99
108
|
msg: (0, _parseError.parseError)(err, `Error running migration ${migration.name}`)
|
@@ -101,4 +110,4 @@ async function runMigrationFile(payload, migration, batch) {
|
|
101
110
|
}
|
102
111
|
}
|
103
112
|
|
104
|
-
//# sourceMappingURL=data:application/json;base64,
|
113
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlIG5vLXJlc3RyaWN0ZWQtc3ludGF4LCBuby1hd2FpdC1pbi1sb29wICovXG5pbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBNaWdyYXRpb24gfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvZGlzdC9leHByZXNzL3R5cGVzJ1xuXG5pbXBvcnQgeyByZWFkTWlncm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S0FBS0MsR0FBRyxLQUFLRixNQUFNLEdBQUcsQ0FBQztRQUFDO1FBQ3BGLE1BQU10QyxRQUFRZ0QsTUFBTSxDQUFDO1lBQ25CbEMsWUFBWTtZQUNabUMsTUFBTTtnQkFDSnpCLE1BQU1RLFVBQVVSLElBQUk7Z0JBQ3BCTjtnQkFDQTJCLFFBQVFEO1lBQ1Y7WUFDQUg7UUFDRjtRQUNBLE1BQU1TLElBQUFBLG9DQUFpQixFQUFDVDtJQUMxQixFQUFFLE9BQU9VLEtBQWM7UUFDckIsTUFBTUMsSUFBQUEsZ0NBQWUsRUFBQ1g7UUFDdEJ6QyxRQUFRSSxNQUFNLENBQUNpRCxLQUFLLENBQUM7WUFDbkJGO1lBQ0E3QyxLQUFLZ0QsSUFBQUEsc0JBQVUsRUFBQ0gsS0FBSyxDQUFDLHdCQUF3QixFQUFFbkIsVUFBVVIsSUFBSSxDQUFDLENBQUM7UUFDbEU7SUFDRjtBQUNGIn0=
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDtE"}
|
package/dist/migrateDown.js
CHANGED
@@ -9,6 +9,9 @@ Object.defineProperty(exports, "migrateDown", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _database = require("payload/database");
|
12
|
+
const _commitTransaction = require("payload/dist/utilities/commitTransaction");
|
13
|
+
const _initTransaction = require("payload/dist/utilities/initTransaction");
|
14
|
+
const _killTransaction = require("payload/dist/utilities/killTransaction");
|
12
15
|
const _migrationTableExists = require("./utilities/migrationTableExists");
|
13
16
|
const _parseError = require("./utilities/parseError");
|
14
17
|
async function migrateDown() {
|
@@ -28,20 +31,22 @@ async function migrateDown() {
|
|
28
31
|
payload.logger.info({
|
29
32
|
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`
|
30
33
|
});
|
31
|
-
|
34
|
+
const latestBatchMigrations = existingMigrations.filter(({ batch })=>batch === latestBatch);
|
35
|
+
for (const migration of latestBatchMigrations){
|
32
36
|
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
33
37
|
if (!migrationFile) {
|
34
38
|
throw new Error(`Migration ${migration.name} not found locally.`);
|
35
39
|
}
|
36
40
|
const start = Date.now();
|
37
|
-
|
41
|
+
const req = {};
|
38
42
|
try {
|
39
43
|
payload.logger.info({
|
40
44
|
msg: `Migrating down: ${migrationFile.name}`
|
41
45
|
});
|
42
|
-
|
46
|
+
await (0, _initTransaction.initTransaction)(req);
|
43
47
|
await migrationFile.down({
|
44
|
-
payload
|
48
|
+
payload,
|
49
|
+
req
|
45
50
|
});
|
46
51
|
payload.logger.info({
|
47
52
|
msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`
|
@@ -51,14 +56,12 @@ async function migrateDown() {
|
|
51
56
|
await payload.delete({
|
52
57
|
id: migration.id,
|
53
58
|
collection: 'payload-migrations',
|
54
|
-
req
|
55
|
-
transactionID
|
56
|
-
}
|
59
|
+
req
|
57
60
|
});
|
58
61
|
}
|
59
|
-
await
|
62
|
+
await (0, _commitTransaction.commitTransaction)(req);
|
60
63
|
} catch (err) {
|
61
|
-
await
|
64
|
+
await (0, _killTransaction.killTransaction)(req);
|
62
65
|
payload.logger.error({
|
63
66
|
err,
|
64
67
|
msg: (0, _parseError.parseError)(err, `Error migrating down ${migrationFile.name}. Rolling back.`)
|
@@ -68,4 +71,4 @@ async function migrateDown() {
|
|
68
71
|
}
|
69
72
|
}
|
70
73
|
|
71
|
-
//# sourceMappingURL=data:application/json;base64,
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZX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PQUFPO1lBQzNELElBQUlGLGFBQWE7Z0JBQ2YsTUFBTXpCLFFBQVE0QixNQUFNLENBQUM7b0JBQ25CQyxJQUFJaEIsVUFBVWdCLEVBQUU7b0JBQ2hCQyxZQUFZO29CQUNaUjtnQkFDRjtZQUNGO1lBRUEsTUFBTVMsSUFBQUEsb0NBQWlCLEVBQUNUO1FBQzFCLEVBQUUsT0FBT1UsS0FBYztZQUNyQixNQUFNQyxJQUFBQSxnQ0FBZSxFQUFDWDtZQUV0QnRCLFFBQVFPLE1BQU0sQ0FBQzJCLEtBQUssQ0FBQztnQkFDbkJGO2dCQUNBdkIsS0FBSzBCLElBQUFBLHNCQUFVLEVBQUNILEtBQUssQ0FBQyxxQkFBcUIsRUFBRWxCLGNBQWNHLElBQUksQ0FBQyxlQUFlLENBQUM7WUFDbEY7WUFDQW1CLFFBQVFDLElBQUksQ0FBQztRQUNmO0lBQ0Y7QUFDRiJ9
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DvE"}
|
package/dist/migrateFresh.js
CHANGED
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "migrateFresh", {
|
|
10
10
|
});
|
11
11
|
const _drizzleorm = require("drizzle-orm");
|
12
12
|
const _database = require("payload/database");
|
13
|
+
const _commitTransaction = require("payload/dist/utilities/commitTransaction");
|
14
|
+
const _initTransaction = require("payload/dist/utilities/initTransaction");
|
15
|
+
const _killTransaction = require("payload/dist/utilities/killTransaction");
|
13
16
|
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
|
14
17
|
const _parseError = require("./utilities/parseError");
|
15
18
|
function _interop_require_default(obj) {
|
@@ -21,9 +24,9 @@ async function migrateFresh() {
|
|
21
24
|
const { payload } = this;
|
22
25
|
const { confirm: acceptWarning } = await (0, _prompts.default)({
|
23
26
|
name: 'confirm',
|
27
|
+
type: 'confirm',
|
24
28
|
initial: false,
|
25
|
-
message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed
|
26
|
-
type: 'confirm'
|
29
|
+
message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`
|
27
30
|
}, {
|
28
31
|
onCancel: ()=>{
|
29
32
|
process.exit(0);
|
@@ -35,14 +38,15 @@ async function migrateFresh() {
|
|
35
38
|
payload.logger.info({
|
36
39
|
msg: `Dropping database.`
|
37
40
|
});
|
38
|
-
await this.drizzle.execute((0, _drizzleorm.sql)`drop schema public cascade
|
41
|
+
await this.drizzle.execute((0, _drizzleorm.sql)`drop schema public cascade;
|
42
|
+
create schema public;`);
|
39
43
|
const migrationFiles = await (0, _database.readMigrationFiles)({
|
40
44
|
payload
|
41
45
|
});
|
42
46
|
payload.logger.debug({
|
43
47
|
msg: `Found ${migrationFiles.length} migration files.`
|
44
48
|
});
|
45
|
-
|
49
|
+
const req = {};
|
46
50
|
// Run all migrate up
|
47
51
|
for (const migration of migrationFiles){
|
48
52
|
payload.logger.info({
|
@@ -50,9 +54,10 @@ async function migrateFresh() {
|
|
50
54
|
});
|
51
55
|
try {
|
52
56
|
const start = Date.now();
|
53
|
-
|
57
|
+
await (0, _initTransaction.initTransaction)(req);
|
54
58
|
await migration.up({
|
55
|
-
payload
|
59
|
+
payload,
|
60
|
+
req
|
56
61
|
});
|
57
62
|
await payload.create({
|
58
63
|
collection: 'payload-migrations',
|
@@ -60,16 +65,14 @@ async function migrateFresh() {
|
|
60
65
|
name: migration.name,
|
61
66
|
batch: 1
|
62
67
|
},
|
63
|
-
req
|
64
|
-
transactionID
|
65
|
-
}
|
68
|
+
req
|
66
69
|
});
|
67
|
-
await
|
70
|
+
await (0, _commitTransaction.commitTransaction)(req);
|
68
71
|
payload.logger.info({
|
69
72
|
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
70
73
|
});
|
71
74
|
} catch (err) {
|
72
|
-
await
|
75
|
+
await (0, _killTransaction.killTransaction)(req);
|
73
76
|
payload.logger.error({
|
74
77
|
err,
|
75
78
|
msg: (0, _parseError.parseError)(err, `Error running migration ${migration.name}. Rolling back`)
|
@@ -78,4 +81,4 @@ async function migrateFresh() {
|
|
78
81
|
}
|
79
82
|
}
|
80
83
|
|
81
|
-
//# sourceMappingURL=data:application/json;base64,
|
84
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlRnJlc2gudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IHNxbCB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHsgcmVhZE1pZ3JhdGlvbkZpbGVzIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcbmltcG9ydCB7IGNvbW1pdFRyYW5zYWN0aW9uIH0gZnJvbSAncGF5bG9hZC9kaXN0L3V0aWxpdGllcy9jb21taXRUcmFuc2FjdGlvbidcbmltcG9ydCB7IGluaXRUcmFuc2FjdGlvbiB9IGZyb20gJ3BheWxvYWQvZGlzdC91dGlsaXRpZXMvaW5pdFRyYW5zYWN0aW9uJ1xuaW1wb3J0IHsga2lsbFRyYW5zYWN0aW9uIH0gZnJvbSAncGF5bG9hZC9kaXN0L3V0aWxpdGllcy9raWxsVHJhbnNhY3Rpb24nXG5pbXBvcnQgcHJvbXB0cyBmcm9tICdwcm9tcHRzJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZX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jtZQUNGO1lBQ0EsTUFBTVcsSUFBQUEsb0NBQWlCLEVBQUNYO1lBRXhCckIsUUFBUVcsTUFBTSxDQUFDQyxJQUFJLENBQUM7Z0JBQUVDLEtBQUssQ0FBQyxXQUFXLEVBQUVTLFVBQVVsQixJQUFJLENBQUMsRUFBRSxFQUFFb0IsS0FBS0MsR0FBRyxLQUFLRixNQUFNLEdBQUcsQ0FBQztZQUFDO1FBQ3RGLEVBQUUsT0FBT1UsS0FBYztZQUNyQixNQUFNQyxJQUFBQSxnQ0FBZSxFQUFDYjtZQUN0QnJCLFFBQVFXLE1BQU0sQ0FBQ3dCLEtBQUssQ0FBQztnQkFDbkJGO2dCQUNBcEIsS0FBS3VCLElBQUFBLHNCQUFVLEVBQUNILEtBQUssQ0FBQyx3QkFBd0IsRUFBRVgsVUFBVWxCLElBQUksQ0FBQyxjQUFjLENBQUM7WUFDaEY7UUFDRjtJQUNGO0FBQ0YifQ==
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,iBAsFzD"}
|
package/dist/migrateRefresh.js
CHANGED
@@ -9,6 +9,9 @@ Object.defineProperty(exports, "migrateRefresh", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _database = require("payload/database");
|
12
|
+
const _commitTransaction = require("payload/dist/utilities/commitTransaction");
|
13
|
+
const _initTransaction = require("payload/dist/utilities/initTransaction");
|
14
|
+
const _killTransaction = require("payload/dist/utilities/killTransaction");
|
12
15
|
const _migrationTableExists = require("./utilities/migrationTableExists");
|
13
16
|
const _parseError = require("./utilities/parseError");
|
14
17
|
async function migrateRefresh() {
|
@@ -28,7 +31,7 @@ async function migrateRefresh() {
|
|
28
31
|
payload.logger.info({
|
29
32
|
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`
|
30
33
|
});
|
31
|
-
|
34
|
+
const req = {};
|
32
35
|
// Reverse order of migrations to rollback
|
33
36
|
existingMigrations.reverse();
|
34
37
|
for (const migration of existingMigrations){
|
@@ -41,9 +44,10 @@ async function migrateRefresh() {
|
|
41
44
|
msg: `Migrating down: ${migration.name}`
|
42
45
|
});
|
43
46
|
const start = Date.now();
|
44
|
-
|
47
|
+
await (0, _initTransaction.initTransaction)(req);
|
45
48
|
await migrationFile.down({
|
46
|
-
payload
|
49
|
+
payload,
|
50
|
+
req
|
47
51
|
});
|
48
52
|
payload.logger.info({
|
49
53
|
msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`
|
@@ -52,9 +56,7 @@ async function migrateRefresh() {
|
|
52
56
|
if (tableExists) {
|
53
57
|
await payload.delete({
|
54
58
|
collection: 'payload-migrations',
|
55
|
-
req
|
56
|
-
transactionID
|
57
|
-
},
|
59
|
+
req,
|
58
60
|
where: {
|
59
61
|
name: {
|
60
62
|
equals: migration.name
|
@@ -62,8 +64,9 @@ async function migrateRefresh() {
|
|
62
64
|
}
|
63
65
|
});
|
64
66
|
}
|
67
|
+
await (0, _commitTransaction.commitTransaction)(req);
|
65
68
|
} catch (err) {
|
66
|
-
await
|
69
|
+
await (0, _killTransaction.killTransaction)(req);
|
67
70
|
payload.logger.error({
|
68
71
|
err,
|
69
72
|
msg: (0, _parseError.parseError)(err, `Error running migration ${migration.name}. Rolling back.`)
|
@@ -78,9 +81,10 @@ async function migrateRefresh() {
|
|
78
81
|
});
|
79
82
|
try {
|
80
83
|
const start = Date.now();
|
81
|
-
|
84
|
+
await (0, _initTransaction.initTransaction)(req);
|
82
85
|
await migration.up({
|
83
|
-
payload
|
86
|
+
payload,
|
87
|
+
req
|
84
88
|
});
|
85
89
|
await payload.create({
|
86
90
|
collection: 'payload-migrations',
|
@@ -88,16 +92,14 @@ async function migrateRefresh() {
|
|
88
92
|
name: migration.name,
|
89
93
|
executed: true
|
90
94
|
},
|
91
|
-
req
|
92
|
-
transactionID
|
93
|
-
}
|
95
|
+
req
|
94
96
|
});
|
95
|
-
await
|
97
|
+
await (0, _commitTransaction.commitTransaction)(req);
|
96
98
|
payload.logger.info({
|
97
99
|
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
98
100
|
});
|
99
101
|
} catch (err) {
|
100
|
-
await
|
102
|
+
await (0, _killTransaction.killTransaction)(req);
|
101
103
|
payload.logger.error({
|
102
104
|
err,
|
103
105
|
msg: (0, _parseError.parseError)(err, `Error running migration ${migration.name}. Rolling back.`)
|
@@ -106,4 +108,4 @@ async function migrateRefresh() {
|
|
106
108
|
}
|
107
109
|
}
|
108
110
|
|
109
|
-
//# sourceMappingURL=data:application/json;base64,
|
111
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9taWdyYXRlUmVmcmVzaC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tYXdhaXQtaW4tbG9vcCAqL1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGdldE1pZ3JhdGlvbnMsIHJlYWRNaWdyYXRpb25GaWxlcyB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5pbXBvcnQgeyBjb21taXRUcmFuc2FjdGlvbiB9IGZyb20gJ3BheWxvYWQvZGlzdC91dGlsaXRpZXMvY29tbWl0VHJhbnNhY3Rpb24nXG5pbXBvcnQgeyBpbml0VHJhbnNhY3Rpb24gfSBmcm9tICdwYXlsb2FkL2Rpc3QvdXRpbGl0aWVzL2luaXRUcmFuc2FjdGlv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
|
1
|
-
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAsEvE"}
|