-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ automatically migrate outdated configs
- Loading branch information
1 parent
496aeba
commit f337f1a
Showing
12 changed files
with
374 additions
and
33 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
db/migration/1726588731621-MigrateOutdatedConfigsToLatestVersion.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,33 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class MigrateOutdatedConfigsToLatestVersion1726588731621 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// we have v3 configs in the database; turn these into v5 configs | ||
// by removing the `data` and `hideLinesOutsideTolerance` properties | ||
await queryRunner.query( | ||
`-- sql | ||
UPDATE chart_configs | ||
SET | ||
patch = JSON_SET( | ||
JSON_REMOVE(patch, '$.data', '$.hideLinesOutsideTolerance'), | ||
'$.$schema', | ||
'https://files.ourworldindata.org/schemas/grapher-schema.005.json' | ||
), | ||
full = JSON_SET( | ||
JSON_REMOVE(full, '$.data', '$.hideLinesOutsideTolerance'), | ||
'$.$schema', | ||
'https://files.ourworldindata.org/schemas/grapher-schema.005.json' | ||
) | ||
WHERE patch ->> '$.$schema' = 'https://files.ourworldindata.org/schemas/grapher-schema.003.json' | ||
` | ||
) | ||
} | ||
|
||
public async down(): Promise<void> { | ||
throw new Error( | ||
"Can't revert migration MigrateOutdatedConfigsToLatestVersion1726588731621" | ||
) | ||
} | ||
} |
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
Oops, something went wrong.