@aeolus-fleet/trierarch-plugin 0.20.4 → 0.21.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.
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Migrate (`prisma migrate deploy`), from wherever the package is installed.
|
|
4
4
|
* Prisma Migrate holds a Postgres advisory lock while it migrates: two
|
|
5
5
|
* processes starting at once never migrate at once; the second waits, then
|
|
6
|
-
* finds nothing left to apply.
|
|
6
|
+
* finds nothing left to apply. Prisma itself waits for that lock only 10
|
|
7
|
+
* seconds, so a migrate that times out on it starts again: it waits as long
|
|
8
|
+
* as the migrate in progress takes.
|
|
7
9
|
*/
|
|
8
10
|
import { spawn } from 'node:child_process';
|
|
9
11
|
import { createRequire } from 'node:module';
|
|
@@ -14,8 +16,21 @@ const PRISMA_CLI = createRequire(import.meta.url).resolve('prisma/build/index.js
|
|
|
14
16
|
export class MigrationError extends Error {
|
|
15
17
|
name = 'MigrationError';
|
|
16
18
|
}
|
|
19
|
+
/** Prisma Migrate's account of a wait for its advisory lock that ran out. */
|
|
20
|
+
const LOCK_TIMED_OUT = 'Timed out trying to acquire a postgres advisory lock';
|
|
17
21
|
/** Migrates the database. Throws a MigrationError holding Prisma's own account when it fails. */
|
|
18
22
|
export async function migrateDatabase(databaseUrl) {
|
|
23
|
+
for (;;) {
|
|
24
|
+
const { code, output } = await deploy(databaseUrl);
|
|
25
|
+
if (code === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!output.includes(LOCK_TIMED_OUT)) {
|
|
29
|
+
throw new MigrationError(`The database could not be migrated. Prisma Migrate says:\n${output.trim()}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function deploy(databaseUrl) {
|
|
19
34
|
const child = spawn(process.execPath, [PRISMA_CLI, 'migrate', 'deploy', '--config', 'prisma.config.ts'], {
|
|
20
35
|
cwd: PACKAGE_ROOT,
|
|
21
36
|
env: {
|
|
@@ -33,8 +48,6 @@ export async function migrateDatabase(databaseUrl) {
|
|
|
33
48
|
const code = await new Promise((resolve) => {
|
|
34
49
|
child.once('close', resolve);
|
|
35
50
|
});
|
|
36
|
-
|
|
37
|
-
throw new MigrationError(`The database could not be migrated. Prisma Migrate says:\n${output.trim()}`);
|
|
38
|
-
}
|
|
51
|
+
return { code, output };
|
|
39
52
|
}
|
|
40
53
|
//# sourceMappingURL=migrate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/adapters/prisma/migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/adapters/prisma/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,uHAAuH;AACvH,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEnF,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,GAAG,gBAAgB,CAAC;CAClC;AAED,6EAA6E;AAC7E,MAAM,cAAc,GAAG,sDAAsD,CAAC;AAE9E,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAAmB;IACvD,SAAS,CAAC;QACR,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QACnD,IAAI,IAAI,KAAK,CAAC,EAAE,C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|
2
2
|
"name": "@aeolus-fleet/trierarch-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Aeolus trierarch plugin: brings machines into the fleet and assigns crew requests to their trierarchs, as a ship of the fleet.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"postpack": "rm LICENSE"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@aeolus-fleet/common": "0.
|
|
42
|
+
"@aeolus-fleet/common": "0.21.0",
|
|
43
43
|
"@prisma/adapter-pg": "^7.10.0",
|
|
44
44
|
"@prisma/client": "^7.10.0",
|
|
45
45
|
"@trpc/server": "^11.19.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"zod": "^4.6.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@aeolus-fleet/core": "0.
|
|
51
|
+
"@aeolus-fleet/core": "0.21.0",
|
|
52
52
|
"@testcontainers/postgresql": "^12.2.0"
|
|
53
53
|
}
|
|
54
54
|
}
|