mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-10-23 18:02:42 +00:00
fix issue with db on conflict
postgress doesn't like that, so two queries
This commit is contained in:
4 files changed
+41
-1
No files matched your search
@@ -1319,6 +1319,21 @@ func (q *Queries) UpsertChannel(ctx context.Context, arg UpsertChannelParams) (C
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertChannelHashOnly = `-- name: UpsertChannelHashOnly :one
|
||||
INSERT INTO channels (channel_hash, last_seen)
|
||||
VALUES ($1, NOW())
|
||||
ON CONFLICT (channel_hash) WHERE key_fingerprint IS NULL DO UPDATE SET
|
||||
last_seen = NOW()
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
func (q *Queries) UpsertChannelHashOnly(ctx context.Context, channelHash []byte) (int32, error) {
|
||||
row := q.db.QueryRow(ctx, upsertChannelHashOnly, channelHash)
|
||||
var id int32
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
const upsertIATA = `-- name: UpsertIATA :exec
|
||||
|
||||
INSERT INTO iata_codes (iata)
|
||||
|
||||
Reference in new issue
Block a user