@remit/drizzle-service 1.0.2 → 2.0.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.
package/package.json
CHANGED
package/src/databases.ts
CHANGED
|
@@ -4,11 +4,13 @@ import type { Db, SqliteStore } from "./db.js";
|
|
|
4
4
|
import { messageDataSchema } from "./schema/message-data.js";
|
|
5
5
|
import { createSqliteDatabase } from "./sqlite-client.js";
|
|
6
6
|
|
|
7
|
-
// The three databases
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
7
|
+
// The three databases an instance runs on (#1420), each on the file its
|
|
8
|
+
// SQLITE_*_DB_PATH names; a self-host points all three at one remit.db. The app
|
|
9
|
+
// database holds what lives in the client: accounts, config, rules, settings
|
|
10
|
+
// and auth. The tenant mail database holds what lives on the IMAP server, plus
|
|
11
|
+
// the local rows that refer to it. The tenant search database holds the
|
|
12
|
+
// full-text index, rebuilt from the mail database, so it never commits together
|
|
13
|
+
// with it.
|
|
12
14
|
export interface SqliteDatabases {
|
|
13
15
|
app: Db<Record<string, unknown>>;
|
|
14
16
|
mail: Db<Record<string, unknown>>;
|
|
@@ -68,15 +68,18 @@ const journalEntries = (set: string): unknown[] => {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* The `<
|
|
72
|
-
* live databases.
|
|
71
|
+
* The `<database>:<table>` pairs `read_schema_version` in the wrapper sums on
|
|
72
|
+
* the live databases, each database read from the file it is configured on.
|
|
73
73
|
*/
|
|
74
74
|
const wrapperCountedTables = (): string[] => {
|
|
75
75
|
const match = read("deploy/vps/remit").match(
|
|
76
|
-
/for p in ((
|
|
76
|
+
/for p in ((?:\$_sv_\w+:__drizzle_migrations_\w+ ?)+); do/,
|
|
77
77
|
);
|
|
78
78
|
assert.ok(match, "the wrapper no longer sums any __drizzle_migrations table");
|
|
79
|
-
return match[1]
|
|
79
|
+
return match[1]
|
|
80
|
+
.trim()
|
|
81
|
+
.split(/\s+/)
|
|
82
|
+
.map((pair) => pair.replace(/^\$_sv_/, ""));
|
|
80
83
|
};
|
|
81
84
|
|
|
82
85
|
describe("schema version accounting", () => {
|
|
@@ -147,7 +150,7 @@ describe("schema version accounting", () => {
|
|
|
147
150
|
test("the wrapper counts exactly the tables the migrator writes", () => {
|
|
148
151
|
assert.deepEqual(
|
|
149
152
|
wrapperCountedTables().sort(),
|
|
150
|
-
sets.map(({ database, table }) => `${database}
|
|
153
|
+
sets.map(({ database, table }) => `${database}:${table}`).sort(),
|
|
151
154
|
);
|
|
152
155
|
});
|
|
153
156
|
|