feat: add optional asset gateway control plane

This commit is contained in:
john
2026-07-12 09:51:13 +08:00
parent 03a79322e4
commit f4d9897072
8 changed files with 449 additions and 1 deletions
+33
View File
@@ -96,6 +96,35 @@ async function ensureForeignKeyDeleteRule(
);
}
/** Creates only the optional asset control-plane tables needed by memind_adm. */
export async function ensureAssetGatewaySchema(pool) {
await pool.query(`
CREATE TABLE IF NOT EXISTS h5_asset_gateway_config (
config_key VARCHAR(32) PRIMARY KEY,
enabled TINYINT(1) NOT NULL DEFAULT 0,
updated_by CHAR(36) NULL,
updated_at BIGINT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
await pool.query(`
CREATE TABLE IF NOT EXISTS h5_asset_plugin_configs (
id CHAR(36) PRIMARY KEY,
plugin_id VARCHAR(64) NOT NULL,
enabled TINYINT(1) NOT NULL DEFAULT 0,
provider VARCHAR(64) NULL,
llm_provider_key_id CHAR(36) NULL,
llm_model VARCHAR(128) NULL,
updated_by CHAR(36) NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE KEY uq_h5_asset_plugin (plugin_id),
KEY idx_h5_asset_plugin_llm_provider (llm_provider_key_id),
CONSTRAINT fk_h5_asset_plugin_llm_provider FOREIGN KEY (llm_provider_key_id)
REFERENCES h5_llm_provider_keys(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
}
export async function migrateSchema(pool) {
const renames = [
['h5_user_sessions', 'goose_session_id', 'agent_session_id'],
@@ -217,6 +246,10 @@ export async function migrateSchema(pool) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
// Optional asset capability control plane. These rows configure no runtime
// worker by themselves; the existing chat/page path remains independent.
await ensureAssetGatewaySchema(pool);
// Shared experience store (etat C). Keep in sync with schema.sql.
await pool.query(`
CREATE TABLE IF NOT EXISTS h5_experience (