mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Set decorator names for default decorators (#1590)
This commit is contained in:
parent
71db872725
commit
04396c4a37
@ -0,0 +1,33 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
MigrationClient.AddMigration(Up_20171027173700, Down_20171027173700)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Up_20171027173700(tx *sql.Tx) error {
|
||||||
|
sql := "UPDATE decorators SET name=? where query=?"
|
||||||
|
|
||||||
|
rows := []struct {
|
||||||
|
name string
|
||||||
|
query string
|
||||||
|
}{
|
||||||
|
{"Host UUID", "SELECT uuid AS host_uuid FROM system_info;"},
|
||||||
|
{"Hostname", "SELECT hostname AS hostname FROM system_info;"},
|
||||||
|
}
|
||||||
|
for _, row := range rows {
|
||||||
|
_, err := tx.Exec(sql, row.name, row.query)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Down_20171027173700(tx *sql.Tx) error {
|
||||||
|
_, err := tx.Exec("UPDATE decorators SET name='' WHERE built_in = TRUE")
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user