[v11.0.x] SQLStore: Disable redundant create and drop unique index migrations on dashboard table (#86867)

SQLStore: Disable redundant create and drop unique index migrations on dashboard table (#86857)

SQLStore: Disable create and drop unique index migrations
(cherry picked from commit a5a3ee9fa3)

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-24 16:37:39 +01:00
committed by GitHub
co-authored by Sofia Papagiannaki
parent 2644311fd0
commit 17b8022ba9
@@ -5,6 +5,18 @@ import (
"xorm.io/xorm"
)
type DummyMigration struct {
migrator.MigrationBase
}
func (m *DummyMigration) SQL(dialect migrator.Dialect) string {
return "code migration"
}
func (m *DummyMigration) Exec(sess *xorm.Session, mgrtr *migrator.Migrator) error {
return nil
}
// FolderUIDMigration is a code migration that populates folder_uid column
type FolderUIDMigration struct {
migrator.MigrationBase
@@ -78,17 +90,13 @@ func AddDashboardFolderMigrations(mg *migrator.Migrator) {
mg.AddMigration("Populate dashboard folder_uid column", &FolderUIDMigration{})
mg.AddMigration("Add unique index for dashboard_org_id_folder_uid_title", migrator.NewAddIndexMigration(migrator.Table{Name: "dashboard"}, &migrator.Index{
Cols: []string{"org_id", "folder_uid", "title"}, Type: migrator.UniqueIndex,
}))
mg.AddMigration("Add unique index for dashboard_org_id_folder_uid_title", &DummyMigration{})
mg.AddMigration("Delete unique index for dashboard_org_id_folder_id_title", migrator.NewDropIndexMigration(migrator.Table{Name: "dashboard"}, &migrator.Index{
Cols: []string{"org_id", "folder_id", "title"}, Type: migrator.UniqueIndex,
}))
mg.AddMigration("Delete unique index for dashboard_org_id_folder_uid_title", migrator.NewDropIndexMigration(migrator.Table{Name: "dashboard"}, &migrator.Index{
Cols: []string{"org_id", "folder_uid", "title"}, Type: migrator.UniqueIndex,
}))
mg.AddMigration("Delete unique index for dashboard_org_id_folder_uid_title", &DummyMigration{})
mg.AddMigration("Add unique index for dashboard_org_id_folder_uid_title_is_folder", migrator.NewAddIndexMigration(migrator.Table{Name: "dashboard"}, &migrator.Index{
Cols: []string{"org_id", "folder_uid", "title", "is_folder"}, Type: migrator.UniqueIndex,