diff --git a/server/src/database/meta.ts b/server/src/database/meta.ts index 8aaee26d..82671213 100644 --- a/server/src/database/meta.ts +++ b/server/src/database/meta.ts @@ -14,6 +14,7 @@ export interface MetaProperties { hasBboxes: "1"; untitledMigrationCompleted: "1"; fieldsNullMigrationCompleted: "1"; + extraInfoNullMigrationCompleted: "1"; } export default class DatabaseMeta { diff --git a/server/src/database/migrations.ts b/server/src/database/migrations.ts index 0b823a55..88c1bef8 100644 --- a/server/src/database/migrations.ts +++ b/server/src/database/migrations.ts @@ -25,6 +25,7 @@ export default class DatabaseMigrations { await this._spatialMigration(); await this._untitledMigration(); await this._fieldsNullMigration(); + await this._extraInfoNullMigration(); } @@ -489,4 +490,23 @@ export default class DatabaseMigrations { await this._db.meta.setMeta("fieldsNullMigrationCompleted", "1"); } + + /** Convert "null" to null for extraInfo */ + async _extraInfoNullMigration(): Promise { + if(await this._db.meta.getMeta("extraInfoNullMigrationCompleted") == "1") + return; + + await this._db.lines.LineModel.update({ + extraInfo: null + }, { + where: { + extraInfo: { + [Op.in]: ["null", "{}"] + } + } + }); + + await this._db.meta.setMeta("extraInfoNullMigrationCompleted", "1"); + } + } diff --git a/server/src/routing/routing.ts b/server/src/routing/routing.ts index 20bf9bac..0f233afb 100644 --- a/server/src/routing/routing.ts +++ b/server/src/routing/routing.ts @@ -56,7 +56,7 @@ export async function calculateRouteForLine(line: Pick= 2) { result.distance = calculateDistance(line.trackPoints); result.time = undefined; - result.extraInfo = {}; + result.extraInfo = undefined; // TODO: ascent/descent? @@ -80,7 +80,7 @@ export async function calculateRouteForLine(line: Pick