@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/drizzle-service",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
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 a self-host instance runs on (#1420). The app database
8
- // holds what lives in the client: accounts, config, rules, settings and auth.
9
- // The tenant mail database holds what lives on the IMAP server, plus the local
10
- // rows that refer to it. The tenant search database holds the full-text index,
11
- // rebuilt from the mail database, so it never commits together with it.
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 `<file>:<table>` pairs `read_schema_version` in the wrapper sums on 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 ((?:\w+\.db:__drizzle_migrations_\w+ ?)+); do/,
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].trim().split(/\s+/);
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}.db:${table}`).sort(),
153
+ sets.map(({ database, table }) => `${database}:${table}`).sort(),
151
154
  );
152
155
  });
153
156