From c89eff016dd7ea34e4919655e023e6edbb877cb7 Mon Sep 17 00:00:00 2001 From: Toni Sharpe Date: Sat, 7 Sep 2024 19:13:44 +0200 Subject: [PATCH] fix 1444 had to incorporate new DB changes * the chart config moved so now the focus is on a specific chart_configs table, not the charts table * didn't see the need to restrict by type, it would be a slower query, * did away with all the 005 schema stuff, assuming the new chart stuff covered that (my merge issues suggest this in fact) --- ...moveHideLinesOutsideToleranceFromConfig.ts | 16 ++++++++++++---- ...224801-UpdateSchemaForChartConfigChange.ts | 19 ------------------- 2 files changed, 12 insertions(+), 23 deletions(-) delete mode 100644 db/migration/1725540224801-UpdateSchemaForChartConfigChange.ts diff --git a/db/migration/1725540224800-RemoveHideLinesOutsideToleranceFromConfig.ts b/db/migration/1725540224800-RemoveHideLinesOutsideToleranceFromConfig.ts index c32d7ca5988..bc95358f8c1 100644 --- a/db/migration/1725540224800-RemoveHideLinesOutsideToleranceFromConfig.ts +++ b/db/migration/1725540224800-RemoveHideLinesOutsideToleranceFromConfig.ts @@ -3,12 +3,20 @@ import { MigrationInterface, QueryRunner } from "typeorm" export class RemoveHideLinesOutsideToleranceFromConfig1725540224800 implements MigrationInterface { + private remove_hide_lines_outside_tolerance(field: string) { + return `${field} = JSON_REMOVE( + ${field}, + '$."hideLinesOutsideTolerance"' + )` + } + public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`-- sql - UPDATE charts - SET config = JSON_REMOVE(config, '$."hideLinesOutsideTolerance"') - WHERE - type = "ScatterPlot" + UPDATE + chart_configs + SET + ${this.remove_hide_lines_outside_tolerance('full')}, + ${this.remove_hide_lines_outside_tolerance('patch')} `) } diff --git a/db/migration/1725540224801-UpdateSchemaForChartConfigChange.ts b/db/migration/1725540224801-UpdateSchemaForChartConfigChange.ts deleted file mode 100644 index b968d271422..00000000000 --- a/db/migration/1725540224801-UpdateSchemaForChartConfigChange.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm" - -export class UpdateSchemaForChartConfigChange1725540224801 - implements MigrationInterface -{ - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`-- sql - UPDATE charts - SET config = JSON_SET(config, '$.$schema', 'https://files.ourworldindata.org/schemas/grapher-schema.005.json'); - `) - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`-- sql - UPDATE charts - SET config = JSON_SET(config, '$.$schema', 'https://files.ourworldindata.org/schemas/grapher-schema.004.json'); - `) - } -}