Skip to content

Commit

Permalink
migrate(entities): drop $.data.availableEntities and $.data from …
Browse files Browse the repository at this point in the history
…chart configs
  • Loading branch information
marcelgerber committed Mar 28, 2024
1 parent e508fa3 commit cf502dd
Showing 1 changed file with 32 additions and 0 deletions.
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
}
}

0 comments on commit cf502dd

Please sign in to comment.