Initial release
[websub-hub] / src / db / postgres / sql / subscription-upsert.sql
1 --
2 INSERT INTO subscription
3 (topic_id, callback, verified, expires, secret, http_remote_addr, http_from)
4 VALUES
5 ($(topicId), $(callback), now(), now() + ($(leaseSeconds) * INTERVAL '1 second'), $(secret), $(httpRemoteAddr), $(httpFrom))
6 ON CONFLICT (topic_id, callback) DO UPDATE
7 SET
8 verified = now(),
9 expires = now() + ($(leaseSeconds) * INTERVAL '1 second'),
10 secret = $(secret),
11 http_remote_addr = $(httpRemoteAddr),
12 http_from = $(httpFrom)
13 RETURNING id