Skip to content

Commit c7d820d

Browse files
rbrennerclaude
andcommitted
fix(db,tests): export table name variables; fix PG omnibus cleanup
Export vectors_table, waypoints_table, users_table from db.ts following the same pattern as memories_table and embed_log_table. All four are set to SQLite bare names by default and overwritten with schema-qualified PG names in the PG init block. Update test_omnibus.ts cleanup() to use all exported table name variables instead of hardcoded strings. Removes the redundant openmemory_vectors fallback that existed only to paper over the missing variable. Verified: clean tsc build + all omnibus tests pass against both SQLite and PostgreSQL (postgres.itsa.house/openmemory_test). Co-Authored-By: Claude <noreply@anthropic.com> AI-Generated: true
1 parent 68bfede commit c7d820d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/openmemory-js/src/core/db.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ let q: q_type;
6060
let vector_store: VectorStore;
6161
let memories_table: string;
6262
let embed_log_table = "embed_logs"; // default for SQLite; overwritten by PG init
63+
let vectors_table = "vectors"; // default for SQLite; overwritten by PG init
64+
let waypoints_table = "waypoints"; // default for SQLite; overwritten by PG init
65+
let users_table = "users"; // default for SQLite; overwritten by PG init
6366
let make_transaction: () => {
6467
begin(): Promise<void>;
6568
commit(): Promise<void>;
@@ -118,6 +121,9 @@ if (is_pg) {
118121
const w = `"${sc}"."openmemory_waypoints"`;
119122
const l = `"${sc}"."openmemory_embed_logs"`;
120123
embed_log_table = l;
124+
vectors_table = v;
125+
waypoints_table = w;
126+
users_table = `"${sc}"."openmemory_users"`;
121127
const f = `"${sc}"."openmemory_memories_fts"`;
122128
const exec = async (sql: string, p: any[] = []) => {
123129
const c = cli || pg;
@@ -1108,4 +1114,4 @@ export const log_maint_op = async (
11081114
}
11091115
};
11101116

1111-
export { q, transaction, make_transaction, all_async, get_async, run_async, memories_table, embed_log_table, vector_store };
1117+
export { q, transaction, make_transaction, all_async, get_async, run_async, memories_table, embed_log_table, vectors_table, waypoints_table, users_table, vector_store };

packages/openmemory-js/tests/test_omnibus.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { Memory } from "../src/core/memory";
3-
import { run_async, q, embed_log_table, make_transaction } from "../src/core/db";
3+
import { run_async, q, embed_log_table, make_transaction, memories_table, vectors_table, waypoints_table, users_table } from "../src/core/db";
44

55
// Mock time for evolutionary stability
66
let mockTime: number | null = null;
@@ -10,11 +10,10 @@ Date.now = () => (mockTime !== null ? mockTime : originalNow());
1010
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
1111

1212
async function cleanup(user_id: string) {
13-
await run_async(`DELETE FROM memories`);
14-
try { await run_async(`DELETE FROM vectors`); } catch { }
15-
try { await run_async(`DELETE FROM openmemory_vectors`); } catch { }
16-
try { await run_async(`DELETE FROM waypoints`); } catch { }
17-
try { await run_async(`DELETE FROM users`); } catch { }
13+
await run_async(`DELETE FROM ${memories_table}`);
14+
try { await run_async(`DELETE FROM ${vectors_table}`); } catch { }
15+
try { await run_async(`DELETE FROM ${waypoints_table}`); } catch { }
16+
try { await run_async(`DELETE FROM ${users_table}`); } catch { }
1817
if (global.gc) global.gc();
1918
}
2019

0 commit comments

Comments
 (0)