-
-
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.
- Loading branch information
1 parent
4e3bf99
commit a587120
Showing
4 changed files
with
655 additions
and
10 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
db/migration/1733850063207-RemoveColorDimensionFromSlopeCharts.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,32 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class RemoveColorDimensionFromSlopeCharts1733850063207 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// remove color dimension for all slope charts | ||
// the y-dimension always comes first and the color dimension second, | ||
// so it's safe to keep the first dimension only | ||
await queryRunner.query(` | ||
-- sql | ||
UPDATE chart_configs | ||
SET | ||
patch = JSON_REPLACE(patch, '$.dimensions', JSON_ARRAY(patch -> '$.dimensions[0]')), | ||
full = JSON_REPLACE(full, '$.dimensions', JSON_ARRAY(full -> '$.dimensions[0]')) | ||
WHERE | ||
chartType = 'SlopeChart' | ||
`) | ||
|
||
// remove the color dimension for slope charts from the chart_dimensions table | ||
await queryRunner.query(` | ||
-- sql | ||
DELETE cd FROM chart_dimensions cd | ||
JOIN charts c ON c.id = cd.chartId | ||
JOIN chart_configs cc ON c.configId = cc.id | ||
WHERE cc.chartType = 'SlopeChart' AND cd.property = 'color' | ||
`) | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
public async down(): Promise<void> {} | ||
} |
Oops, something went wrong.