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

SQLStore: Disable create and drop unique index migrations
This commit is contained in:
Sofia Papagiannaki 2024-04-24 15:25:43 +01:00 committed by GitHub
parent 17a3ec52b6
commit a5a3ee9fa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,