Skip to content

Commit 4e75074

Browse files
committed
🗃️ fix: fix db migration
1 parent ecd1d25 commit 4e75074

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/database/core/db.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class LocalDB extends Dexie {
147147

148148
upgradeToV8 = async (trans: Transaction) => {
149149
const users = trans.table('users');
150-
users.toCollection().modify((user: DB_User) => {
150+
await users.toCollection().modify((user: DB_User) => {
151151
if (user.settings) {
152152
user.settings = MigrationLLMSettings.migrateSettings(user.settings as any);
153153
}

src/migrations/FromV3ToV4/index.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ export class MigrationV3ToV4 implements Migration {
3333
languageModel: {
3434
...res,
3535
azure,
36-
ollama: this.migrateProvider(ollama),
36+
ollama: ollama && this.migrateProvider(ollama),
3737
openai,
38-
openrouter: this.migrateProvider(openrouter),
39-
togetherai: this.migrateProvider(togetherai),
38+
openrouter: openrouter && this.migrateProvider(openrouter),
39+
togetherai: togetherai && this.migrateProvider(togetherai),
4040
},
4141
};
4242
};
4343

4444
static migrateOpenAI = (
45-
openai: V3OpenAIConfig,
45+
openai?: V3OpenAIConfig,
4646
): { azure: V4AzureOpenAIConfig; openai: V4ProviderConfig } => {
47+
if (!openai)
48+
return {
49+
azure: { apiKey: '', enabled: false },
50+
openai: { apiKey: '', enabled: true },
51+
};
52+
4753
if (openai.useAzure) {
4854
return {
4955
azure: {

src/migrations/FromV3ToV4/types/v3.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface V3Settings {
4444
defaultAgent: any;
4545
fontSize: number;
4646
language: string;
47-
languageModel: V3LLMConfig;
47+
languageModel?: Partial<V3LLMConfig>;
4848
neutralColor?: string;
4949
password: string;
5050
primaryColor?: string;

src/migrations/FromV3ToV4/types/v4.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export interface V4AzureOpenAIConfig extends V4ProviderConfig {
1717
}
1818

1919
export interface V4lLLMConfig
20-
extends Omit<V3LLMConfig, 'ollama' | 'openAI' | 'openrouter' | 'togetherai'> {
21-
azure: V4AzureOpenAIConfig;
22-
ollama: V4ProviderConfig;
20+
extends Omit<Partial<V3LLMConfig>, 'ollama' | 'openAI' | 'openrouter' | 'togetherai'> {
21+
azure?: V4AzureOpenAIConfig;
22+
ollama?: V4ProviderConfig;
2323
openai: V4ProviderConfig;
24-
openrouter: V4ProviderConfig;
25-
togetherai: V4ProviderConfig;
24+
openrouter?: V4ProviderConfig;
25+
togetherai?: V4ProviderConfig;
2626
}
2727

2828
/**

0 commit comments

Comments
 (0)