@payloadcms/db-postgres 0.1.0-beta.13 → 0.1.0-beta.14
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createMigrationTable.d.ts","sourceRoot":"","sources":["../../src/utilities/createMigrationTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,eAAO,MAAM,oBAAoB,qBAA0B,QAAQ,IAAI,
|
1
|
+
{"version":3,"file":"createMigrationTable.d.ts","sourceRoot":"","sources":["../../src/utilities/createMigrationTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,eAAO,MAAM,oBAAoB,qBAA0B,QAAQ,IAAI,CAQtE,CAAA"}
|
@@ -14,10 +14,9 @@ const createMigrationTable = async (db)=>{
|
|
14
14
|
"id" serial PRIMARY KEY NOT NULL,
|
15
15
|
"name" varchar,
|
16
16
|
"batch" numeric,
|
17
|
-
"schema" jsonb,
|
18
17
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
19
18
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
20
19
|
);`);
|
21
20
|
};
|
22
21
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvY3JlYXRlTWlncmF0aW9uVGFibGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHsgRHJpenpsZURCIH0gZnJvbSAnLi4vdHlwZXMnXG5cbmV4cG9ydCBjb25zdCBjcmVhdGVNaWdyYXRpb25UYWJsZSA9IGFzeW5jIChkYjogRHJpenpsZURCKTogUHJvbWlzZTx2b2lkPiA9PiB7XG4gIGF3YWl0IGRiLmV4ZWN1dGUoc3FsYENSRUFURSBUQUJMRSBJRiBOT1QgRVhJU1RTIFwicGF5bG9hZF9taWdyYXRpb25zXCIgKFxuICBcImlkXCIgc2VyaWFsIFBSSU1BUlkgS0VZIE5PVCBOVUxMLFxuICBcIm5hbWVcIiB2YXJjaGFyLFxuICBcImJhdGNoXCIgbnVtZXJpYyxcbiAgXCJ1cGRhdGVkX2F0XCIgdGltZXN0YW1wKDMpIHdpdGggdGltZSB6b25lIERFRkFVTFQgbm93KCkgTk9UIE5VTEwsXG4gIFwiY3JlYXRlZF9hdFwiIHRpbWVzdGFtcCgzKSB3aXRoIHRpbWUgem9uZSBERUZBVUxUIG5vdygpIE5PVCBOVUxMXG4pO2ApXG59XG4iXSwibmFtZXMiOlsiY3JlYXRlTWlncmF0aW9uVGFibGUiLCJkYiIsImV4ZWN1dGUiLCJzcWwiXSwibWFwcGluZ3MiOiI7Ozs7K0JBSWFBOzs7ZUFBQUE7Ozs0QkFKTztBQUliLE1BQU1BLHVCQUF1QixPQUFPQztJQUN6QyxNQUFNQSxHQUFHQyxPQUFPLENBQUNDLElBQUFBLGVBQUcsQ0FBQSxDQUFDOzs7Ozs7RUFNckIsQ0FBQztBQUNIIn0=
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,85 @@
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvbWlncmF0aW9ucy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBNaWdyYXRpb24gfSBmcm9tICdwYX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