/** * mode_model_config —— 场景 → 模型链(小配置表),定义抄录自 schema.md(唯一事实源)。 * * 无 version 列:配置变更的缓存失效走 @drama/config-source 的版本机制(version = max(updated_at))。 * `chain` JSON 承载 `[{provider,model}, ...fallback]`,扩展加键不加列。`{ tableName, buildTable }` * 形态与 llm_model.cjs 同构,经 @drama/db applyCurrentSchema 建表。 */ const tableName = 'mode_model_config' /** * @param {import('knex').Knex.CreateTableBuilder} t * @param {import('knex').Knex} db */ function buildTable(t, db) { t.bigIncrements('id').unsigned().primary() t.string('mode', 64).notNullable() t.json('chain').notNullable() t.boolean('enabled').notNullable().defaultTo(1) t.datetime('created_at', { precision: 3 }).notNullable().defaultTo(db.raw('CURRENT_TIMESTAMP(3)')) t.datetime('updated_at', { precision: 3 }) .notNullable() .defaultTo(db.raw('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)')) t.unique(['mode'], { indexName: 'uk_mode' }) } module.exports = { tableName, buildTable }