-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: copy bind from models index * fix(download): settings * fix: better regex * fix: version check
- Loading branch information
Showing
11 changed files
with
86 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 17 additions & 7 deletions
24
server/src/cli/commands/postinstall/migration/migtation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import {$} from 'execa'; | ||
import {packageJSON} from '../../../../storage/config.js'; | ||
import semver from 'semver'; | ||
|
||
import v0313 from './versions/v0.3.13.js'; | ||
import v209 from './versions/v2.0.9.js'; | ||
|
||
const MIGRATIONS = [v0313, v209]; | ||
|
||
export async function runMigrations() { | ||
const {stdout: oldVersion} = await $`npm -g info catai version`; | ||
const fromVersion = Number(oldVersion.trim()[0] || '-'); | ||
const toVersion = Number(packageJSON.version.trim()[0]); | ||
|
||
for (let i = fromVersion; i < toVersion; i++) { | ||
try { | ||
const migration = await import(`./versions/v${i}.js`); | ||
await migration.default(); | ||
} catch {} | ||
const fromVersion = oldVersion.trim(); | ||
const toVersion = packageJSON.version.trim(); | ||
|
||
if (!fromVersion) return; | ||
|
||
for (const migration of MIGRATIONS) { | ||
if (semver.lte(toVersion, migration.version)) continue; | ||
|
||
if (semver.gte(migration.version, fromVersion)) { | ||
console.log(`CatAI Migrated to v${migration.version}`); | ||
await migration.migration(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
server/src/cli/commands/postinstall/migration/versions/v2.0.9.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import AppDB from '../../../../../storage/app-db.js'; | ||
|
||
async function migration() { | ||
for (const [, value] of Object.entries(AppDB.db.models)) { | ||
value.settings ??= {} as any; | ||
value.settings.bind ??= (value as any).bindClass; | ||
value.defaultSettings.bind ??= (value as any).bindClass; | ||
} | ||
await AppDB.saveDB(); | ||
} | ||
|
||
export default { | ||
version: '2.0.9', | ||
migration | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters