From 51b10639245b34f0bc4060977ee96ff70f43e2d5 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 20 Jun 2026 11:39:08 -0500 Subject: [PATCH] fix: use information_schema check instead of DROP COLUMN IF EXISTS MySQL 8.0.x does not support IF EXISTS on ALTER TABLE DROP COLUMN. Query information_schema.COLUMNS first to check column existence. --- models/migrations/v1_27/v358.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/models/migrations/v1_27/v358.go b/models/migrations/v1_27/v358.go index d70b9bb117..dfcbe8499c 100644 --- a/models/migrations/v1_27/v358.go +++ b/models/migrations/v1_27/v358.go @@ -8,9 +8,17 @@ import "xorm.io/xorm" // DropDisplayNameColumns removes the display_name column from repo_manifest // and update_stream_config. Display name is now computed from extension_type + name. func DropDisplayNameColumns(x *xorm.Engine) error { - if _, err := x.Exec("ALTER TABLE repo_manifest DROP COLUMN IF EXISTS display_name"); err != nil { - return err + // MySQL 8.0.x does not support DROP COLUMN IF EXISTS — check first. + for _, table := range []string{"repo_manifest", "update_stream_config"} { + var count int + if _, err := x.SQL("SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = 'display_name'", table).Get(&count); err != nil { + return err + } + if count > 0 { + if _, err := x.Exec("ALTER TABLE `" + table + "` DROP COLUMN `display_name`"); err != nil { + return err + } + } } - _, err := x.Exec("ALTER TABLE update_stream_config DROP COLUMN IF EXISTS display_name") - return err + return nil } -- 2.52.0