Dashboards: Add feature restore dashboards backend (#83131)

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
Ezequiel Victorero
2024-05-16 14:36:26 -03:00
committed by GitHub
co-authored by Sofia Papagiannaki
parent edae5fc791
commit 42d75ac737
30 changed files with 1230 additions and 96 deletions
@@ -234,4 +234,13 @@ func addDashboardMigration(mg *Migrator) {
mg.AddMigration("Add isPublic for dashboard", NewAddColumnMigration(dashboardV2, &Column{
Name: "is_public", Type: DB_Bool, Nullable: false, Default: "0",
}))
mg.AddMigration("Add deleted for dashboard", NewAddColumnMigration(dashboardV2, &Column{
Name: "deleted", Type: DB_DateTime, Nullable: true,
}))
mg.AddMigration("Add index for deleted", NewAddIndexMigration(dashboardV2, &Index{
Cols: []string{"deleted"},
Type: IndexType,
}))
}
@@ -66,6 +66,7 @@ func (b *Builder) buildSelect() {
dashboard_tag.term,
dashboard.is_folder,
dashboard.folder_id,
dashboard.deleted,
folder.uid AS folder_uid,
`)
if b.Features.IsEnabledGlobally(featuremgmt.FlagNestedFolders) {
@@ -198,3 +198,15 @@ var _ model.FilterWhere = &FolderWithAlertsFilter{}
func (f FolderWithAlertsFilter) Where() (string, []any) {
return "EXISTS (SELECT 1 FROM alert_rule WHERE alert_rule.namespace_uid = dashboard.uid)", nil
}
type DeletedFilter struct {
Deleted bool
}
func (f DeletedFilter) Where() (string, []any) {
if f.Deleted {
return "dashboard.deleted IS NOT NULL", nil
}
return "dashboard.deleted IS NULL", nil
}