1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

Tolerate missing app metadata in app url migration

This commit is contained in:
Rory Powell 2022-01-31 17:28:45 +00:00
parent a063274133
commit b63aa71366

View file

@ -9,7 +9,16 @@ import { getAppUrl } from "../../api/controllers/application"
* Add the url to the app metadata if it doesn't exist * Add the url to the app metadata if it doesn't exist
*/ */
export const run = async (appDb: any) => { export const run = async (appDb: any) => {
const metadata = await appDb.get(DocumentTypes.APP_METADATA) let metadata
try {
metadata = await appDb.get(DocumentTypes.APP_METADATA)
} catch (e) {
// sometimes the metadata document doesn't exist
// exit early instead of failing the migration
console.error("Error retrieving app metadata. Skipping", e)
return
}
if (!metadata.url) { if (!metadata.url) {
const context = { const context = {
request: { request: {
@ -20,6 +29,6 @@ export const run = async (appDb: any) => {
} }
metadata.url = getAppUrl(context) metadata.url = getAppUrl(context)
console.log(`Adding url to app: ${metadata.url}`) console.log(`Adding url to app: ${metadata.url}`)
}
await appDb.put(metadata) await appDb.put(metadata)
} }
}