From 957365191976d587da5b1c715755c3210fc2dd32 Mon Sep 17 00:00:00 2001 From: Mengnan Gong Date: Wed, 25 Jan 2023 17:23:24 +0800 Subject: [PATCH] add a migration script to trigger a reprocessing of the entities Signed-off-by: Mengnan Gong --- .changeset/dull-gorillas-sing.md | 5 +++ .../20230125085746_trigger_reprocessing.js | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .changeset/dull-gorillas-sing.md create mode 100644 plugins/catalog-backend/migrations/20230125085746_trigger_reprocessing.js diff --git a/.changeset/dull-gorillas-sing.md b/.changeset/dull-gorillas-sing.md new file mode 100644 index 0000000000..99246bea1c --- /dev/null +++ b/.changeset/dull-gorillas-sing.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +The previous migration that adds the `search.original_value` column may leave some of the entities not updated. Add a migration script to trigger a reprocessing of the entities. diff --git a/plugins/catalog-backend/migrations/20230125085746_trigger_reprocessing.js b/plugins/catalog-backend/migrations/20230125085746_trigger_reprocessing.js new file mode 100644 index 0000000000..9bd30723cd --- /dev/null +++ b/plugins/catalog-backend/migrations/20230125085746_trigger_reprocessing.js @@ -0,0 +1,33 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// @ts-check + +/** + * @param { import("knex").Knex } knex + */ +exports.up = async function up(knex) { + await knex('final_entities').update({ hash: '' }); + await knex('refresh_state').update({ + result_hash: '', + next_update_at: knex.fn.now(), + }); +}; + +/** + * @param { import("knex").Knex } _knex + */ +exports.down = async function down(_knex) {};