ensureMetaTable (db/meta.ts)

hippo-memory · src/db/meta.ts · typescript · MIT
database, tag:embed-classified

Manages SQLite metadata for schema versioning and binary compatibility.

// Source: https://github.com/kitfunso/hippo-memory | License: MIT | Copyright 2026 Keith So
// Provided via justclaw.it.com; keep this notice with the code.
import { compareSemver } from '../util/version.js';
import type { DatabaseSyncLike } from './sqlite.js';
import { tableExists } from './tables.js';

export const META_TABLE_DDL = `
    CREATE TABLE IF NOT EXISTS meta (
      key TEXT PRIMARY KEY,
      value TEXT NOT NULL
    );
  `;

export function ensureMetaTable(db: DatabaseSyncLike): void {
  db.exec(META_TABLE_DDL);
}

export function getSchemaVersion(db: DatabaseSyncLike): number {
  if (!tableExists(db, 'meta')) return 0;
  // SAFETY: row's shape matches the single `value` column named in the
  // SELECT above.
  const row = db.prepare(`SELECT value FROM meta WHERE key = 'sche

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key