Add migration to ensure 'All Hosts' is complete (#1330)
Due to recreating the 'All Hosts' label in #1282, we get inconsistent counts for hosts that have not checked in since that migration. This seems acceptable for other labels, but it is important that 'All Hosts' really includes all the hosts. This migration adds all the hosts into that label. Fixes #1329
This commit is contained in:
committed by
GitHub
parent
f713c1fc08
commit
8a0ae4ad9b
@@ -1,5 +1,7 @@
|
||||
* Fix issue with Distributed Query Pack results full screen feature that broke the browser scrolling abilities
|
||||
|
||||
* Fix bug in which host counts in the sidebar did not match up with displayed hosts.
|
||||
|
||||
## Kolide 1.0.1 (February 27, 2017) ##
|
||||
|
||||
* Fix an issue that prevented users from replacing deleted labels with a new label of the same name.
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func init() {
|
||||
MigrationClient.AddMigration(Up_20170301093653, Down_20170301093653)
|
||||
}
|
||||
|
||||
func Up_20170301093653(tx *sql.Tx) error {
|
||||
// Insert any host not currently in 'All Hosts' label into the label
|
||||
_, err := tx.Exec(`
|
||||
INSERT IGNORE INTO label_query_executions (
|
||||
host_id,
|
||||
label_id,
|
||||
matches
|
||||
) SELECT
|
||||
id as host_id,
|
||||
(SELECT id as label_id FROM labels WHERE name = 'All Hosts' AND label_type = ?),
|
||||
true as matches
|
||||
FROM hosts
|
||||
`,
|
||||
kolide.LabelTypeBuiltIn)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "adding hosts to 'All Hosts'")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Down_20170301093653(tx *sql.Tx) error {
|
||||
// This operation not reversible
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user