@jskit-ai/database-runtime 0.1.251 → 0.1.253
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/package.json +14 -3
- package/src/server/database.js +46 -0
- package/src/server/databaseSetup.js +42 -13
- package/src/server/foreignKeyMigrations.js +122 -0
- package/src/server/knexFactory.js +1 -0
- package/src/server/knexMigrationConfig.js +131 -10
- package/src/server/providers/DatabaseProvider.js +11 -43
- package/src/server/types.js +20 -0
- package/src/shared/duplicateEntry.js +15 -1
- package/src/shared/index.js +3 -1
- package/src/shared/repositoryOptions.js +50 -12
- package/src/shared/transactionManager.js +17 -18
- package/test/databaseSetup.test.js +8 -2
- package/test/duplicateEntry.test.js +11 -1
- package/test/foreignKeyMigrations.postgres.test.js +92 -0
- package/test/foreignKeyMigrations.test.js +48 -0
- package/test/knexMigrationConfig.test.js +276 -3
- package/test/packageMetadata.test.js +1 -1
- package/test/providerRuntime.test.js +1 -2
- package/test/repositoryOptions.test.js +15 -0
|
@@ -11,6 +11,6 @@ test("database-runtime exposes migration configuration without authoring mutatio
|
|
|
11
11
|
assert.equal(Object.hasOwn(packageJson.jskit.metadata.apiSummary, "containerTokens"), false);
|
|
12
12
|
assert.deepEqual(packageJson.jskit.capabilities, {
|
|
13
13
|
provides: ["runtime.database"],
|
|
14
|
-
requires: ["runtime.database.driver"]
|
|
14
|
+
requires: ["runtime.database.driver", "runtime.env"]
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -2,6 +2,7 @@ import test from "node:test";
|
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import {
|
|
4
4
|
isDeadlockError,
|
|
5
|
+
joinOrOpenTransaction,
|
|
5
6
|
lockScopedRecordId,
|
|
6
7
|
normalizeDbRecordId,
|
|
7
8
|
parseJsonValue,
|
|
@@ -135,3 +136,17 @@ test("runInTransaction retries only deadlocks of the outermost transaction, a fe
|
|
|
135
136
|
assert.equal(await attemptsUntilRejected(fakeKnex(), victim, { retries: 0 }), 1);
|
|
136
137
|
assert.equal(await attemptsUntilRejected(fakeKnex({ isTransaction: true }), victim), 1, "A savepoint leaves the retry to its outermost transaction");
|
|
137
138
|
});
|
|
139
|
+
|
|
140
|
+
test("joinOrOpenTransaction runs work in the caller's transaction, else in one it opens", async () => {
|
|
141
|
+
const opened = [];
|
|
142
|
+
const withTransaction = async (work) => {
|
|
143
|
+
opened.push("opened");
|
|
144
|
+
return work("new-trx");
|
|
145
|
+
};
|
|
146
|
+
const work = async (trx) => `ran in ${trx}`;
|
|
147
|
+
|
|
148
|
+
assert.equal(await joinOrOpenTransaction({ trx: "caller-trx" }, withTransaction, work), "ran in caller-trx");
|
|
149
|
+
assert.deepEqual(opened, []);
|
|
150
|
+
assert.equal(await joinOrOpenTransaction({}, withTransaction, work), "ran in new-trx");
|
|
151
|
+
assert.deepEqual(opened, ["opened"]);
|
|
152
|
+
});
|