fleet/server/datastore/mysql/migrations/data/20210819120215_ChangeTeamScheduleNames.go
Tomas Touceda a1ceebf267
Make team schedule names more user friendly and hide them from host pack stats (#1737)
* Make team schedule names more user friendly and hide them from host pack stats

* Delete test for a different bug and add migration

* Update name template
2021-08-23 14:23:47 -03:00

24 lines
539 B
Go

package data
import (
"database/sql"
"github.com/pkg/errors"
)
func init() {
MigrationClient.AddMigration(Up_20210819120215, Down_20210819120215)
}
func Up_20210819120215(tx *sql.Tx) error {
sql := `UPDATE packs SET name = CONCAT('Team: ', (select name from teams where id=(CAST(SUBSTRING_INDEX(pack_type,'-',-1) AS UNSIGNED)))) WHERE pack_type LIKE 'team-%'`
if _, err := tx.Exec(sql); err != nil {
return errors.Wrap(err, "update team pack names")
}
return nil
}
func Down_20210819120215(tx *sql.Tx) error {
return nil
}