workspace migration logs (#6038)

* workspace migration logs

* add try catches around all the migrations
This commit is contained in:
Jack Kavanagh 2023-06-21 17:45:18 +02:00 committed by GitHub
parent 63754de659
commit b4857c7a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 18 deletions

View File

@ -49,8 +49,13 @@ export function init() {
}
export function migrate(doc: CookieJar) {
doc = migrateCookieId(doc);
return doc;
try {
doc = migrateCookieId(doc);
return doc;
} catch (e) {
console.log('[db] Error during cookie jar migration', e);
throw e;
}
}
export async function create(patch: Partial<CookieJar>) {

View File

@ -224,10 +224,15 @@ export function newAuth(type: string, oldAuth: RequestAuthentication = {}): Requ
}
export function migrate(doc: Request): Request {
doc = migrateBody(doc);
doc = migrateWeirdUrls(doc);
doc = migrateAuthType(doc);
return doc;
try {
doc = migrateBody(doc);
doc = migrateWeirdUrls(doc);
doc = migrateAuthType(doc);
return doc;
} catch (e) {
console.log('[db] Error during request migration', e);
throw e;
}
}
export function create(patch: Partial<Request> = {}) {

View File

@ -84,8 +84,13 @@ export function init(): BaseResponse {
}
export async function migrate(doc: Response) {
doc = await migrateBodyCompression(doc);
return doc;
try {
doc = await migrateBodyCompression(doc);
return doc;
} catch (e) {
console.log('[db] Error during response migration', e);
throw e;
}
}
export function hookDatabaseInit(consoleLog: typeof console.log = console.log) {

View File

@ -78,8 +78,13 @@ export function init(): BaseSettings {
}
export function migrate(doc: Settings) {
doc = migrateEnsureHotKeys(doc);
return doc;
try {
doc = migrateEnsureHotKeys(doc);
return doc;
} catch (e) {
console.log('[db] Error during settings migration', e);
throw e;
}
}
export async function all() {

View File

@ -51,14 +51,19 @@ export const init = (): BaseWorkspace => ({
});
export async function migrate(doc: Workspace) {
doc = await _migrateExtractClientCertificates(doc);
doc = await _migrateEnsureName(doc);
await models.apiSpec.getOrCreateForParentId(doc._id, {
fileName: doc.name,
});
doc = _migrateScope(doc);
doc = _migrateIntoDefaultProject(doc);
return doc;
try {
doc = await _migrateExtractClientCertificates(doc);
doc = await _migrateEnsureName(doc);
await models.apiSpec.getOrCreateForParentId(doc._id, {
fileName: doc.name,
});
doc = _migrateScope(doc);
doc = _migrateIntoDefaultProject(doc);
return doc;
} catch (e) {
console.log('[db] Error during workspace migration', e);
throw e;
}
}
export function getById(id?: string) {