Skip to content

Commit 76cd58a

Browse files
committed
feat(memory): wire Brain._initialize to MigrationRunner
1 parent 5963d1c commit 76cd58a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/memory/retrieval/store/Brain.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
DDL_ARCHIVE_ACCESS_LOG,
4646
DDL_ARCHIVE_ACCESS_LOG_IDX,
4747
} from '../../archive/SqlStorageMemoryArchive.js';
48-
import { migrateV1ToV2 } from './migrations/v1-to-v2.js';
48+
import { MigrationRunner, MIGRATIONS, LATEST_SCHEMA_VERSION } from './migrations/index.js';
4949
import { PORTABLE_TABLES, PORTABLE_TABLE_PRIMARY_KEYS } from './portable-tables.js';
5050

5151
/**
@@ -68,9 +68,9 @@ function deriveBrainIdFromPath(dbPath: string): string {
6868
// ---------------------------------------------------------------------------
6969
// Constants
7070
// ---------------------------------------------------------------------------
71-
72-
/** Current schema version. Increment when breaking schema changes are made. */
73-
const SCHEMA_VERSION = '2';
71+
// SCHEMA_VERSION moved to migrations/index.ts as LATEST_SCHEMA_VERSION
72+
// (derived from the highest registered migration, so adding v2-to-v3.ts
73+
// auto-bumps the seed value).
7474

7575
// ---------------------------------------------------------------------------
7676
// DDL — full schema
@@ -553,7 +553,7 @@ export class Brain {
553553
const fkPragma = features.dialect.pragma('foreign_keys', 'ON');
554554
if (fkPragma) await adapter.exec(fkPragma);
555555

556-
await migrateV1ToV2(adapter, features, brainId);
556+
await MigrationRunner.runPending(adapter, features, brainId, MIGRATIONS);
557557
await brain._initSchema();
558558
await brain._seedMeta();
559559

@@ -702,7 +702,7 @@ export class Brain {
702702
// leaves the connection in an implicit-commit state.
703703
await this._adapter.run(
704704
dialect.insertOrIgnore('brain_meta', ['brain_id', 'key', 'value'], ['?', '?', '?']),
705-
[this._brainId, 'schema_version', SCHEMA_VERSION],
705+
[this._brainId, 'schema_version', String(LATEST_SCHEMA_VERSION)],
706706
);
707707
await this._adapter.run(
708708
dialect.insertOrIgnore('brain_meta', ['brain_id', 'key', 'value'], ['?', '?', '?']),

0 commit comments

Comments
 (0)