mautrix-whatsapp/database/upgrades/2022-05-12-backfillqueue-dispatch-time.go
Sumner Evans 1d70cbff48
backfill queue: add dispatch time, remove time end to table
* the dispatch time is going to be what the completed time used to be
* the time end column was always nil, so I got rid of it
2022-05-15 21:42:38 -06:00

25 lines
514 B
Go

package upgrades
import (
"database/sql"
)
func init() {
upgrades[44] = upgrade{"Add dispatch time to backfill queue", func(tx *sql.Tx, ctx context) error {
// First, add dispatch_time TIMESTAMP column
_, err := tx.Exec(`
ALTER TABLE backfill_queue
ADD COLUMN dispatch_time TIMESTAMP
`)
if err != nil {
return err
}
// For all previous jobs, set dispatch time to the completed time.
_, err = tx.Exec(`
UPDATE backfill_queue
SET dispatch_time=completed_at
`)
return err
}}
}