Dashboards / Folders: delete related data (permissions, stars, tags, versions, annotations) when deleting a dashboard or a folder (#28826)

* Dashboard: delete related data when deleting a dashboard or a folder

* fix migrations order

* apply PR feedback
This commit is contained in:
Agnès Toulet
2020-11-06 09:02:31 +01:00
committed by GitHub
parent 0cbf034483
commit f0421ed08e
4 changed files with 36 additions and 3 deletions
@@ -46,4 +46,7 @@ INSERT INTO dashboard_acl
`
mg.AddMigration("save default acl rules in dashboard_acl table", NewRawSqlMigration(rawSQL))
mg.AddMigration("delete acl rules for deleted dashboards and folders", NewRawSqlMigration(
"DELETE FROM dashboard_acl WHERE dashboard_id NOT IN (SELECT id FROM dashboard) AND dashboard_id != -1"))
}
@@ -219,4 +219,10 @@ func addDashboardMigration(mg *Migrator) {
Cols: []string{"title"},
Type: IndexType,
}))
mg.AddMigration("delete tags for deleted dashboards", NewRawSqlMigration(
"DELETE FROM dashboard_tag WHERE dashboard_id NOT IN (SELECT id FROM dashboard)"))
mg.AddMigration("delete stars for deleted dashboards", NewRawSqlMigration(
"DELETE FROM star WHERE dashboard_id NOT IN (SELECT id FROM dashboard)"))
}