Add FolderUID for library elements (#79572)

* Add FolderUID in missing places for libraryelements

* Add migration for FolderUID in library elements table

* Add Folder UIDs tolibrary panels

* Adjust dashboard import with folder uid

* Fix lint

* Rename back FolderUID to UID

* Remove default

* Check if folderUID is nil

* Add unique indes on org_id,folder_uid,name and kind

* Update pkg/services/libraryelements/database.go

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Fix folder integration test, with unique index on library elements

* Make folder uids nullable and rewrite migration query

* Use dashboard uid instead of folder_uid

* Adjust test

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
idafurjes
2024-03-01 10:16:33 +01:00
committed by GitHub
parent 2182cc47ac
commit 2532047e7a
17 changed files with 229 additions and 157 deletions

View File

@ -448,10 +448,12 @@ func TestIntegrationNestedFolderService(t *testing.T) {
// nolint:staticcheck
libraryElementCmd.FolderID = parent.ID
libraryElementCmd.FolderUID = &parent.UID
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)
// nolint:staticcheck
libraryElementCmd.FolderID = subfolder.ID
libraryElementCmd.FolderUID = &subfolder.UID
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)
@ -528,10 +530,12 @@ func TestIntegrationNestedFolderService(t *testing.T) {
// nolint:staticcheck
libraryElementCmd.FolderID = parent.ID
libraryElementCmd.FolderUID = &parent.UID
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)
// nolint:staticcheck
libraryElementCmd.FolderID = subfolder.ID
libraryElementCmd.FolderUID = &subfolder.UID
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)
@ -667,11 +671,13 @@ func TestIntegrationNestedFolderService(t *testing.T) {
_ = createRule(t, alertStore, subfolder.UID, "sub alert")
// nolint:staticcheck
libraryElementCmd.FolderID = subfolder.ID
libraryElementCmd.FolderUID = &subPanel.FolderUID
subPanel, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)
}
// nolint:staticcheck
libraryElementCmd.FolderID = parent.ID
libraryElementCmd.FolderUID = &parent.UID
parentPanel, err := lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
require.NoError(t, err)