-
-
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.
migrate(entities): drop
$.data.availableEntities
and $.data
from …
…chart configs
- Loading branch information
1 parent
e508fa3
commit cf502dd
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
db/migration/1711580214803-RemoveAvailableEntitiesFromChartConfigs.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 RemoveAvailableEntitiesFromChartConfigs1711580214803 | ||
implements MigrationInterface | ||
{ | ||
// Removes `$.data.availableEntities` from chart configs | ||
// In doing that, we can also remove the whole `$.data` object, because it is not used anymore | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const configColumns = [ | ||
{ table: "charts", column: "config" }, | ||
{ table: "chart_revisions", column: "config" }, | ||
{ table: "suggested_chart_revisions", column: "suggestedConfig" }, | ||
{ table: "variables", column: "grapherConfigAdmin" }, | ||
{ table: "variables", column: "grapherConfigETL" }, | ||
] | ||
|
||
for (const { table, column } of configColumns) { | ||
await queryRunner.query( | ||
`-- sql | ||
UPDATE ?? | ||
SET ?? = JSON_REMOVE(??, "$.data") | ||
WHERE JSON_CONTAINS_PATH(??, "one", "$.data") | ||
`, | ||
[table, column, column, column] | ||
) | ||
} | ||
} | ||
|
||
public async down(): Promise<void> { | ||
return | ||
} | ||
} |