feat(database): add automatic migration on startup and enhance text analysis cache source

This commit is contained in:
MythEclipse
2026-05-31 23:01:38 +07:00
parent 96cd0cfc62
commit 7607282db2
13 changed files with 178 additions and 14 deletions
+16 -1
View File
@@ -39,9 +39,10 @@ describe("loadConfig", () => {
expect(config.AI_ANALYSIS_DEBOUNCE_MS).toBe(500);
expect(config.AI_ANALYSIS_RECOVERY_INTERVAL_MS).toBe(15000);
expect(config.AI_ANALYSIS_ERROR_COOLDOWN_MS).toBe(30000);
expect(config.AI_ANALYSIS_MAX_BATCH_SIZE).toBe(25);
expect(config.AI_ANALYSIS_MAX_BATCH_SIZE).toBe(200);
expect(config.AI_ANALYSIS_MAX_CONTEXT_TOKENS).toBe(8000);
expect(config.AI_ANALYSIS_CONTEXT_MESSAGE_LIMIT).toBe(20);
expect(config.AUTO_MIGRATE_ON_STARTUP).toBe(true);
});
it("coerces AI analysis tuning values", async () => {
@@ -107,4 +108,18 @@ describe("loadConfig", () => {
expect(config.TEXT_CHANNEL_ID).toBe("text-channel");
expect(config.EFFECTIVE_VOICE_GUILD_ID).toBe("voice-guild");
});
it("allows disabling startup migrations explicitly", async () => {
process.env = {
...originalEnv,
DISCORD_TOKEN: "token",
AUTO_MIGRATE_ON_STARTUP: "false",
NODE_ENV: "test",
};
const { loadConfig } = await import("../src/config");
const config = loadConfig(process.env);
expect(config.AUTO_MIGRATE_ON_STARTUP).toBe(false);
});
});