Fix error when migrating packs and scheduled query has been deleted. (#1851)

Fixes #1850
This commit is contained in:
Zachary Wasserman 2018-06-26 09:54:45 -07:00 committed by GitHub
parent 87fd9a2c8b
commit 293ca56040
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,15 @@ func Up_20171219164727(tx *sql.Tx) error {
return errors.Wrap(err, "populating query_name column")
}
// Clear out any scheduled queries that didn't correspond to a query
query = `
DELETE FROM scheduled_queries
WHERE query_name IS NULL
`
if _, err := tx.Exec(query); err != nil {
return errors.Wrap(err, "clear invalid scheduled queries")
}
// Add not null constraint
query = `
ALTER TABLE scheduled_queries