Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

744 B
Raw Blame
import type Database from 'better-sqlite3';

function tableColumnNames(db: Database.Database, tableName: string): string[] {
  return db
    .prepare(`PRAGMA table_info('${tableName}')`)
    .all()
    .map((row) => String((row as { name: unknown }).name));
}

function run(db: Database.Database): void {
  const columns = new Set(tableColumnNames(db, 'sessions'));
  if (!columns.has('list_preview')) {
    db.exec('ALTER TABLE sessions ADD COLUMN list_preview text');
  }
  if (!columns.has('list_preview_role')) {
    db.exec('ALTER TABLE sessions ADD COLUMN list_preview_role text');
  }
  if (!columns.has('list_message_count')) {
    db.exec('ALTER TABLE sessions ADD COLUMN list_message_count integer');
  }
}

module.exports = { run };