Make the constraint explicit rather than inferred (#1506)

This commit is contained in:
Jake Sanders 2020-04-08 23:52:35 +01:00 committed by GitHub
parent bf8ebf8ad2
commit 1e7cd8c484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,9 +277,9 @@ func (s *sqlStore) initDB() error {
s.readOffset = readOffset
write, err := s.db.Prepare(fmt.Sprintf(`INSERT INTO %s.%s(key, value, expiry)
VALUES ($1, $2::bytea, $3)
ON CONFLICT (key)
ON CONFLICT ON CONSTRAINT %s_pkey
DO UPDATE
SET value = EXCLUDED.value, expiry = EXCLUDED.expiry;`, s.database, s.table))
SET value = EXCLUDED.value, expiry = EXCLUDED.expiry;`, s.database, s.table, s.table))
if err != nil {
return errors.Wrap(err, "Write statement couldn't be prepared")
}