@jskit-ai/database-runtime 0.1.277 → 0.1.279

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/CHANGELOG.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - `@jskit-ai/database-runtime/server/tableCollationMigrations` exports `migrateInExistingCollation(knex, { migration, up, tables, referenceTables, foreignKeys })`. On MySQL and MariaDB it runs a migration's `up` with each table it creates in the character set and collation of the first of `referenceTables` that exists, not the database's default, which differs from the tables' on a database restored onto a server with another default (a key between them was refused, errno 150). Before that it repairs, each only in the state it measures: an empty table of an unrecorded migration that lacks one of its `foreignKeys` is dropped and created again (with rows it refuses); a table of a recorded migration in another collation is converted when no stored character can be lost, and refused otherwise, then gains its missing `foreignKeys` (`addMissingForeignKey`). It changes nothing where everything matches, and does nothing on PostgreSQL and SQLite or before any reference table exists. Released table migrations call it from a companion, `<name>-collation.cjs`, which Knex sorts just before them.
5
6
  - **Breaking:** `PROD_DB_NAME` is gone. A test database, or one of its numbered copies, named like `STAGING_DB_NAME` or `PRODUCTION_DB_NAME`, the Staging and Production databases an application names on a server it shares with its test databases, is refused as one named like `PROD_DB_NAME` was (`... must differ from the application's DB_NAME, DATABASE_URL, STAGING_DB_NAME and PRODUCTION_DB_NAME (name).`). While `PROD_DB_NAME`, or another variable JSKIT no longer reads, is set, `requireDisposableDatabase`, `prepareTestDatabases` and `testDatabaseRun` (before it chooses one file at a time) refuse, naming what replaced it.
6
7
  - **Breaking:** test databases are refused in staging and production (`APP_ENV`), not under `NODE_ENV=production`: `Test databases are never prepared when APP_ENV is staging.` and `Package data tests never run when APP_ENV is production.`; a missing `APP_ENV` throws.
7
8
  - **Behaviour change.** `jskit test --databases` gives every test file the snapshot, rows included: a test database an earlier file of the run used is restored before the next file takes it. It was restored only when its tables or migration ledger had changed (a migration test), so rows an earlier file wrote stayed, and a file's result could depend on which files ran before it on the same copy (for example an app's first account, which only an empty database admits). The run's first file on each copy still takes it as the run restored it; each later file costs one restore, a template copy on PostgreSQL and a table rebuild on MySQL and MariaDB.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/database-runtime",
3
- "version": "0.1.277",
3
+ "version": "0.1.279",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -10,6 +10,7 @@
10
10
  "./server/databaseSetup": "./src/server/databaseSetup.js",
11
11
  "./server/knexMigrationConfig": "./src/server/knexMigrationConfig.js",
12
12
  "./server/foreignKeyMigrations": "./src/server/foreignKeyMigrations.js",
13
+ "./server/tableCollationMigrations": "./src/server/tableCollationMigrations.js",
13
14
  "./server/testDatabases": "./src/server/testDatabases.js",
14
15
  "./server/types": "./src/server/types.js",
15
16
  "./shared": "./src/shared/index.js",
@@ -65,6 +66,10 @@
65
66
  "subpath": "./server/foreignKeyMigrations",
66
67
  "summary": "Adds a single-column foreign key only when it is missing, refusing rows without a parent, for constraints migrations on fresh and already-migrated databases, and lists every foreign key the connected database holds."
67
68
  },
69
+ {
70
+ "subpath": "./server/tableCollationMigrations",
71
+ "summary": "Runs a migration that creates tables, on MySQL and MariaDB, with each new table in the collation of the existing tables rather than the database's default, and repairs a table that default left, for a released migration's companion and for new migrations."
72
+ },
68
73
  {
69
74
  "subpath": "./server/testDatabases",
70
75
  "summary": "Gives each test file or browser worker running at once its own disposable copy of TEST_DB_NAME or BROWSER_TEST_DB_NAME, restored from a schema snapshot keyed by the migrations' names and contents (MySQL, MariaDB and PostgreSQL), counts the statements a piece of work sends, for query-count guards, and gives a package's own data test its Knex: SQLite in memory, or a PostgreSQL schema of its own on a DB_CLIENT=pg run (createPackageTestKnex)."
@@ -82,6 +87,6 @@
82
87
  }
83
88
  },
84
89
  "peerDependencies": {
85
- "@jskit-ai/kernel": "0.2.28"
90
+ "@jskit-ai/kernel": "0.2.29"
86
91
  }
87
92
  }
@@ -0,0 +1,235 @@
1
+ import { detectDialectFromClient } from "../shared/dialect.js";
2
+ import { addMissingForeignKey, hasForeignKey } from "./foreignKeyMigrations.js";
3
+
4
+ // MySQL and MariaDB create a table without a character set or collation of its own in the database's default. A
5
+ // database restored onto a server with another default keeps its tables' collation, so a package migration that
6
+ // creates a table there made it in another collation than the tables it joins, and MariaDB refused a key between
7
+ // them (errno 150), leaving the new table behind, empty and unrecorded. These helpers create a migration's tables in
8
+ // the collation of the tables already there, and repair what the database's default left.
9
+
10
+ // A collation name as information_schema gives it; its character set is the part before the first "_" ("binary"
11
+ // has none), and Knex writes both into its SQL as they are.
12
+ const COLLATION_NAME = /^[a-z0-9]+(?:_[a-z0-9]+)*$/u;
13
+
14
+ // The character sets whose every character the key holds, so converting a table's text to it loses none.
15
+ const HOLDS_EVERY_CHARACTER_OF = Object.freeze({
16
+ utf8mb4: Object.freeze(["utf8mb4", "utf8mb3", "utf8", "latin1", "ascii"])
17
+ });
18
+
19
+ /**
20
+ * A collation and its character set.
21
+ * @typedef {object} TableCollation
22
+ * @property {string} collation
23
+ * @property {string} charset
24
+ */
25
+
26
+ /**
27
+ * The collation of a table, and the character sets of its text columns.
28
+ * @typedef {object} TableState
29
+ * @property {string} collation
30
+ * @property {string[]} charsets
31
+ */
32
+
33
+ /**
34
+ * A collation and the character set its name starts with.
35
+ * @param {string} collation
36
+ * @returns {TableCollation}
37
+ */
38
+ function collationNamed(collation) {
39
+ if (!COLLATION_NAME.test(collation)) {
40
+ throw new Error(`Unexpected collation name ${JSON.stringify(collation)} in information_schema.`);
41
+ }
42
+ return Object.freeze({
43
+ collation,
44
+ charset: collation.split("_")[0]
45
+ });
46
+ }
47
+
48
+ /**
49
+ * The collation of each of the tables that exists in the connected database, and its text columns' character sets.
50
+ * @param {import("./types.js").RuntimeKnex} knex
51
+ * @param {readonly string[]} tableNames
52
+ * @returns {Promise<Map<string, TableState>>}
53
+ */
54
+ async function tableStates(knex, tableNames) {
55
+ const tables = await knex("information_schema.TABLES")
56
+ .whereRaw("TABLE_SCHEMA = DATABASE()")
57
+ .where({ TABLE_TYPE: "BASE TABLE" })
58
+ .whereIn("TABLE_NAME", tableNames)
59
+ .select({ tableName: "TABLE_NAME", collation: "TABLE_COLLATION" });
60
+ const columns = await knex("information_schema.COLUMNS")
61
+ .whereRaw("TABLE_SCHEMA = DATABASE()")
62
+ .whereNotNull("CHARACTER_SET_NAME")
63
+ .whereIn("TABLE_NAME", tableNames)
64
+ .distinct({ tableName: "TABLE_NAME", charset: "CHARACTER_SET_NAME" });
65
+ return new Map(tables.map(({ tableName, collation }) => [tableName, Object.freeze({
66
+ collation,
67
+ charsets: columns.filter((column) => column.tableName === tableName).map((column) => column.charset)
68
+ })]));
69
+ }
70
+
71
+ /**
72
+ * Whether Knex has recorded the migration as run.
73
+ * @param {import("./types.js").RuntimeKnex} knex
74
+ * @param {string} migration The migration's file name, as Knex records it.
75
+ */
76
+ async function isRecorded(knex, migration) {
77
+ const ledger = knex.client.config.migrations?.tableName || "knex_migrations";
78
+ if (!(await knex.schema.hasTable(ledger))) {
79
+ return false;
80
+ }
81
+ return Boolean(await knex(ledger).where({ name: migration }).first("name"));
82
+ }
83
+
84
+ /**
85
+ * Whether the table holds no row.
86
+ * @param {import("./types.js").RuntimeKnex} knex
87
+ * @param {string} tableName
88
+ */
89
+ async function isEmpty(knex, tableName) {
90
+ return !(await knex(tableName).first(knex.raw("1 AS present")));
91
+ }
92
+
93
+ /**
94
+ * A Knex that is `knex` in every way, except that each table its schema builder creates has the collation.
95
+ * @param {import("./types.js").RuntimeKnex} knex
96
+ * @param {TableCollation} collation
97
+ * @returns {import("./types.js").RuntimeKnex}
98
+ */
99
+ function creatingTablesIn(knex, { collation, charset }) {
100
+ return new Proxy(knex, {
101
+ get(target, property) {
102
+ const value = Reflect.get(target, property);
103
+ if (property !== "schema") {
104
+ return value;
105
+ }
106
+ // Each read of knex.schema is a new builder, so changing this one changes no other.
107
+ const createTable = value.createTable;
108
+ value.createTable = function createTableInCollation(tableName, build) {
109
+ return createTable.call(this, tableName, function buildInCollation(table) {
110
+ table.charset(charset);
111
+ table.collate(collation);
112
+ return build.call(this, table);
113
+ });
114
+ };
115
+ return value;
116
+ }
117
+ });
118
+ }
119
+
120
+ /**
121
+ * Converts a table to the collation when no stored character can be lost: its text columns are all in a character
122
+ * set the target holds, or it has no row. Otherwise it refuses and changes nothing.
123
+ * @param {import("./types.js").RuntimeKnex} knex
124
+ * @param {string} tableName
125
+ * @param {TableState} state
126
+ * @param {TableCollation} target
127
+ */
128
+ async function convertTable(knex, tableName, state, { collation, charset }) {
129
+ const holds = HOLDS_EVERY_CHARACTER_OF[charset] || [charset];
130
+ const lossy = state.charsets.filter((columnCharset) => !holds.includes(columnCharset));
131
+ if (lossy.length > 0 && !(await isEmpty(knex, tableName))) {
132
+ throw new Error(
133
+ `Cannot convert ${tableName} from ${state.collation} to ${collation}: it holds rows in ${lossy.join(", ")}, ` +
134
+ `which ${charset} may not hold. Convert it by hand after a backup, then migrate again; the migration changed nothing.`
135
+ );
136
+ }
137
+ await knex.raw(`ALTER TABLE ?? CONVERT TO CHARACTER SET ${charset} COLLATE ${collation}`, [tableName]);
138
+ }
139
+
140
+ /**
141
+ * A table of a recorded migration: converted to the reference collation when it has another, then given each of its
142
+ * keys it lacks.
143
+ * @param {import("./types.js").RuntimeKnex} knex
144
+ * @param {string} tableName
145
+ * @param {TableState} state
146
+ * @param {TableCollation} reference
147
+ * @param {readonly import("./foreignKeyMigrations.js").ForeignKey[]} keys
148
+ */
149
+ async function repairRecordedTable(knex, tableName, state, reference, keys) {
150
+ if (state.collation !== reference.collation) {
151
+ await convertTable(knex, tableName, state, reference);
152
+ }
153
+ for (const key of keys) {
154
+ await addMissingForeignKey(knex, key);
155
+ }
156
+ }
157
+
158
+ /**
159
+ * A table of a migration Knex has not recorded that lacks one of its keys is what a refused key left: dropped when it
160
+ * holds no row, so the migration creates it again, and refused with rows. A table with its keys is left as it is.
161
+ * @param {import("./types.js").RuntimeKnex} knex
162
+ * @param {string} migration
163
+ * @param {string} tableName
164
+ * @param {readonly import("./foreignKeyMigrations.js").ForeignKey[]} keys
165
+ */
166
+ async function dropTableLeftWithoutKey(knex, migration, tableName, keys) {
167
+ const missing = [];
168
+ for (const key of keys) {
169
+ if (!(await hasForeignKey(knex, key))) missing.push(key);
170
+ }
171
+ if (missing.length === 0) {
172
+ return;
173
+ }
174
+ if (!(await isEmpty(knex, tableName))) {
175
+ throw new Error(
176
+ `${tableName} holds rows but has no foreign key to ${missing.map((key) => key.parentTable).join(", ")}, and ` +
177
+ `${migration} has not run. Back up and repair ${tableName} by hand, then migrate again; the migration changed nothing.`
178
+ );
179
+ }
180
+ await knex.schema.dropTable(tableName);
181
+ }
182
+
183
+ /**
184
+ * Runs a migration that creates tables, on MySQL and MariaDB, with each table it creates in the character set and
185
+ * collation of the first of `referenceTables` that exists, instead of the database's default. A released migration is
186
+ * run this way by a companion file named after it with "-collation" (`<name>-collation.cjs`): Knex sorts that file
187
+ * just before the released one, runs it on every database that has not run it yet, and the released migration then
188
+ * finds its tables in place and skips creating them. A new migration can call it with its own name and `up`.
189
+ *
190
+ * Before that, it repairs what the database's default left, each only in the state it measures, and changes nothing
191
+ * on a database whose tables are all in place, in the reference collation, with their keys:
192
+ * - a table of the migration that Knex has not recorded, that holds no row and lacks one of its `foreignKeys`, is
193
+ * what a refused key left: it is dropped, and created again. A table with rows in that state is refused.
194
+ * - a table of a migration Knex has recorded, in another collation, is converted to the reference collation when no
195
+ * character can be lost (`convertTable`), and then gains any of its `foreignKeys` it lacks (`addMissingForeignKey`,
196
+ * which refuses rows without a parent).
197
+ *
198
+ * On other databases, or before any of `referenceTables` exists, it does nothing and the migration runs as released.
199
+ * @param {import("./types.js").RuntimeKnex} knex The migration's Knex or transaction.
200
+ * @param {object} options
201
+ * @param {string} options.migration The released migration's file name, as Knex records it.
202
+ * @param {(knex: import("./types.js").RuntimeKnex) => Promise<unknown>} options.up The released migration's `up`.
203
+ * @param {readonly string[]} options.tables The tables the released migration creates.
204
+ * @param {readonly string[]} options.referenceTables The tables whose collation new tables take, the first that exists.
205
+ * @param {readonly import("./foreignKeyMigrations.js").ForeignKey[]} [options.foreignKeys] The keys the released
206
+ * migration creates with its tables to tables created before it, which a different collation made MariaDB refuse.
207
+ */
208
+ async function migrateInExistingCollation(knex, { migration, up, tables, referenceTables, foreignKeys = [] }) {
209
+ if (detectDialectFromClient(knex) !== "mysql") {
210
+ return;
211
+ }
212
+ const references = await tableStates(knex, referenceTables);
213
+ const referenceTable = referenceTables.find((tableName) => references.has(tableName));
214
+ if (!referenceTable) {
215
+ return;
216
+ }
217
+ const reference = collationNamed(references.get(referenceTable).collation);
218
+ const recorded = await isRecorded(knex, migration);
219
+ const states = await tableStates(knex, tables);
220
+
221
+ for (const tableName of tables.filter((name) => states.has(name))) {
222
+ const keys = foreignKeys.filter((key) => key.tableName === tableName);
223
+ if (recorded) {
224
+ await repairRecordedTable(knex, tableName, states.get(tableName), reference, keys);
225
+ } else {
226
+ await dropTableLeftWithoutKey(knex, migration, tableName, keys);
227
+ }
228
+ }
229
+
230
+ if (!recorded) {
231
+ await up(creatingTablesIn(knex, reference));
232
+ }
233
+ }
234
+
235
+ export { migrateInExistingCollation };
@@ -0,0 +1,137 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import knexFactory from "knex";
4
+ import { requireTestDatabase } from "../src/server/testDatabases.js";
5
+ import { migrateInExistingCollation } from "../src/server/tableCollationMigrations.js";
6
+
7
+ // migrateInExistingCollation's refusals and conversions on MariaDB/MySQL, each in a database of the test's own whose
8
+ // default collation is not its tables'. Local auth's migration test (auth-provider-local-db-core) runs it through
9
+ // Knex's migrator on the states a refused key left.
10
+
11
+ const TABLES_COLLATION = "utf8mb4_general_ci";
12
+ const OTHER_DEFAULT = "utf8mb4_unicode_ci";
13
+ const KEY = { tableName: "children", columnName: "parent_id", parentTable: "parents", name: "fk_children_parent", onDelete: "CASCADE" };
14
+
15
+ /**
16
+ * A database of the test's own, named after TEST_DB_NAME with the suffix and dropped after the test, its default
17
+ * OTHER_DEFAULT, with a `parents` table in TABLES_COLLATION.
18
+ * @param {import("node:test").TestContext} context
19
+ * @param {string} suffix
20
+ */
21
+ async function openDatabase(context, suffix) {
22
+ const name = `${requireTestDatabase(process.env)}_${suffix}`;
23
+ const server = { host: process.env.DB_HOST, port: Number(process.env.DB_PORT) || 3306, user: process.env.DB_USER, password: process.env.DB_PASSWORD };
24
+ const admin = knexFactory({ client: "mysql2", connection: server, pool: { min: 0, max: 1 } });
25
+ await admin.raw("DROP DATABASE IF EXISTS ??", [name]);
26
+ await admin.raw(`CREATE DATABASE ?? CHARACTER SET utf8mb4 COLLATE ${OTHER_DEFAULT}`, [name]);
27
+ const knex = knexFactory({ client: "mysql2", connection: { ...server, database: name }, pool: { min: 0, max: 1 } });
28
+ context.after(async () => {
29
+ try {
30
+ await knex.destroy();
31
+ await admin.raw("DROP DATABASE IF EXISTS ??", [name]);
32
+ } finally {
33
+ await admin.destroy();
34
+ }
35
+ });
36
+ await knex.raw(`CREATE TABLE parents (id VARCHAR(80) PRIMARY KEY) CHARACTER SET utf8mb4 COLLATE ${TABLES_COLLATION}`);
37
+ await knex("parents").insert({ id: "p1" });
38
+ return knex;
39
+ }
40
+
41
+ /** Records the migration as Knex does. */
42
+ async function record(knex, name) {
43
+ await knex.schema.createTable("knex_migrations", (table) => {
44
+ table.increments("id");
45
+ table.string("name");
46
+ table.integer("batch");
47
+ table.timestamp("migration_time");
48
+ });
49
+ await knex("knex_migrations").insert({ name, batch: 1, migration_time: knex.fn.now() });
50
+ }
51
+
52
+ async function collationOf(knex, tableName) {
53
+ const [[row]] = await knex.raw(
54
+ "SELECT TABLE_COLLATION AS collation FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?",
55
+ [tableName]
56
+ );
57
+ return row?.collation;
58
+ }
59
+
60
+ // The released migration: a child table with a key to `parents`, created unless it exists.
61
+ async function createChildren(knex) {
62
+ if (await knex.schema.hasTable("children")) return;
63
+ await knex.schema.createTable("children", (table) => {
64
+ table.string("id", 80).primary();
65
+ table.string("parent_id", 80).notNullable();
66
+ table.text("note").nullable();
67
+ table.foreign(["parent_id"], KEY.name).references(["id"]).inTable("parents").onDelete("CASCADE");
68
+ });
69
+ }
70
+
71
+ const options = { migration: "children.cjs", up: createChildren, tables: ["children"], referenceTables: ["parents"], foreignKeys: [KEY] };
72
+
73
+ test("a new table takes its reference table's collation, so its key to it is accepted", async (context) => {
74
+ const knex = await openDatabase(context, "tcm_create");
75
+ await assert.rejects(createChildren(knex), /errno: 150|incorrectly formed/u, "the database's default is refused");
76
+ await knex.schema.dropTable("children");
77
+
78
+ await migrateInExistingCollation(knex, options);
79
+
80
+ assert.equal(await collationOf(knex, "children"), TABLES_COLLATION);
81
+ await knex("children").insert({ id: "c1", parent_id: "p1" });
82
+ await knex("parents").where({ id: "p1" }).delete();
83
+ assert.deepEqual(await knex("children").select("id"), [], "the key cascades");
84
+ });
85
+
86
+ test("an unrecorded table left without its key is refused while it holds rows, and changes nothing", async (context) => {
87
+ const knex = await openDatabase(context, "tcm_rows");
88
+ await knex.raw(`CREATE TABLE children (id VARCHAR(80) PRIMARY KEY, parent_id VARCHAR(80) NOT NULL) COLLATE ${OTHER_DEFAULT}`);
89
+ await knex("children").insert({ id: "c1", parent_id: "p1" });
90
+
91
+ await assert.rejects(migrateInExistingCollation(knex, options), /children holds rows but has no foreign key to parents, and children\.cjs has not run/u);
92
+
93
+ assert.equal(await collationOf(knex, "children"), OTHER_DEFAULT);
94
+ assert.deepEqual(await knex("children").select("id", "parent_id"), [{ id: "c1", parent_id: "p1" }]);
95
+ });
96
+
97
+ test("a recorded table is converted when its characters fit, and refused, unchanged, when they may not", async (context) => {
98
+ const knex = await openDatabase(context, "tcm_convert");
99
+ await record(knex, "children.cjs");
100
+ await knex.raw(`CREATE TABLE children (id VARCHAR(80) PRIMARY KEY, parent_id VARCHAR(80) NOT NULL, note TEXT) CHARACTER SET latin1`);
101
+ await knex("children").insert({ id: "c1", parent_id: "p1", note: "café" });
102
+
103
+ await migrateInExistingCollation(knex, options);
104
+
105
+ assert.equal(await collationOf(knex, "children"), TABLES_COLLATION, "latin1 text fits utf8mb4");
106
+ assert.deepEqual(await knex("children").select("note"), [{ note: "café" }]);
107
+ assert.deepEqual(await knex.raw("SELECT 1 FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = DATABASE() AND CONSTRAINT_NAME = ?", [KEY.name]).then(([rows]) => rows.length), 1, "the missing key is added");
108
+
109
+ await knex.raw("CREATE TABLE narrow_parents (id VARCHAR(80) PRIMARY KEY) CHARACTER SET latin1");
110
+ await knex.raw(`CREATE TABLE wide (id VARCHAR(80) PRIMARY KEY) CHARACTER SET utf8mb4 COLLATE ${OTHER_DEFAULT}`);
111
+ await knex("wide").insert({ id: "😀" });
112
+ await assert.rejects(
113
+ migrateInExistingCollation(knex, { migration: "children.cjs", up: createChildren, tables: ["wide"], referenceTables: ["narrow_parents"] }),
114
+ /Cannot convert wide from utf8mb4_unicode_ci to latin1_swedish_ci: it holds rows in utf8mb4/u
115
+ );
116
+ assert.equal(await collationOf(knex, "wide"), OTHER_DEFAULT);
117
+ assert.deepEqual(await knex("wide").select("id"), [{ id: "😀" }]);
118
+ });
119
+
120
+ test("everything in place and matching changes nothing, and other databases are left to the released migration", async (context) => {
121
+ const knex = await openDatabase(context, "tcm_match");
122
+ await record(knex, "children.cjs");
123
+ await knex.raw(`CREATE TABLE children (id VARCHAR(80) PRIMARY KEY, parent_id VARCHAR(80) NOT NULL,
124
+ CONSTRAINT ${KEY.name} FOREIGN KEY (parent_id) REFERENCES parents (id) ON DELETE CASCADE) COLLATE ${TABLES_COLLATION}`);
125
+ const statements = [];
126
+ knex.on("query", ({ sql }) => statements.push(sql));
127
+
128
+ await migrateInExistingCollation(knex, options);
129
+
130
+ assert.deepEqual(statements.filter((sql) => !/^\s*select\b/iu.test(sql)), [], "only reads");
131
+
132
+ const sqlite = knexFactory({ client: "better-sqlite3", connection: { filename: ":memory:" }, useNullAsDefault: true });
133
+ context.after(() => sqlite.destroy());
134
+ let ran = false;
135
+ await migrateInExistingCollation(sqlite, { ...options, up: async () => { ran = true; } });
136
+ assert.equal(ran, false, "the released migration runs itself after its companion");
137
+ });