From 0e710fc837e6314620fe6327ecf68c4a82c6c039 Mon Sep 17 00:00:00 2001 From: kapaje Date: Tue, 1 Apr 2025 22:51:04 +0200 Subject: [PATCH] Update refresh_state table column for mysql databases Signed-off-by: kapaje --- .changeset/chubby-cougars-run.md | 6 +++ ...0401200503_update_refresh_state_columns.js | 43 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .changeset/chubby-cougars-run.md create mode 100644 plugins/catalog-backend/migrations/20250401200503_update_refresh_state_columns.js diff --git a/.changeset/chubby-cougars-run.md b/.changeset/chubby-cougars-run.md new file mode 100644 index 0000000000..deb954ef6b --- /dev/null +++ b/.changeset/chubby-cougars-run.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +This patch addresses an issue identified in Backstage when configured with a MySQL database. If an entity of type location +(e..all.yaml) has more than 70 referenced entities, clicking "Refresh" does not update the referenced entities as expected. This occurs because the TEXT type in MySQL has a limit of 65,535 bytes, which is insufficient to store all the referenced entities, causing the refresh operation to fail. diff --git a/plugins/catalog-backend/migrations/20250401200503_update_refresh_state_columns.js b/plugins/catalog-backend/migrations/20250401200503_update_refresh_state_columns.js new file mode 100644 index 0000000000..091dc896af --- /dev/null +++ b/plugins/catalog-backend/migrations/20250401200503_update_refresh_state_columns.js @@ -0,0 +1,43 @@ +/* + * Copyright 2024 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. + */ +/** + * @param {import('knex').Knex} knex + * @returns {Promise} + */ +exports.up = async function up(knex) { + const isMySQL = knex.client.config.client.includes('mysql'); + // update the columns to longtext for MySQL + if (isMySQL) { + await knex.schema.alterTable('refresh_state', table => { + table.text('unprocessed_entity', 'longtext').alter(); + table.text('cache', 'longtext').alter(); + }); + } +}; + +/** + * @param {import('knex').Knex} knex + * @returns {Promise} + */ +exports.down = async function down(knex) { + const isMySQL = knex.client.config.client.includes('mysql'); + if (isMySQL) { + await knex.schema.alterTable('refresh_state', table => { + table.text('unprocessed_entity').alter(); + table.text('cache').alter(); + }); + } +};