Migrate the server upsert query to use database time (#1214)

* Migrate the server upsert query to use database time

This ensures that we are using consistent ideas of time regardless of
the local time on each worker (for this query).

* Fix insert part of the upsert query
pull/1222/head
Jeff Mitchell 5 years ago committed by GitHub
parent a33d1922a1
commit 1ec0ba0a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,13 +5,13 @@ const (
insert into server
(private_id, type, description, address, update_time)
values
($1, $2, $3, $4, $5)
($1, $2, $3, $4, now())
on conflict on constraint server_pkey
do update set
type = $2,
description = $3,
address = $4,
update_time = $5;
update_time = now();
`
deleteWhereCreateTimeSql = `create_time < $1`
deleteTagsSql = `server_id = $1`

@ -136,7 +136,6 @@ func (r *Repository) UpsertServer(ctx context.Context, server *Server, opt ...Op
server.Type,
server.Description,
server.Address,
time.Now().Format(time.RFC3339),
})
if err != nil {
return errors.Wrap(err, op+":Upsert")

Loading…
Cancel
Save