Update "updated" column on duplicate keys
continuous-integration/drone/push Build is passing Details

master
Peter Stuifzand 3 years ago
parent 85ac5fb6f2
commit 5452cabf7e

@ -25,8 +25,15 @@ func (s *postgres) Close() error {
}
func (s *postgres) Subscribe(topic string, sub Subscriber) error {
_, err := s.db.Exec(
`INSERT INTO "subscribers" ("topic", "callback", "lease_seconds", "secret", "created") VALUES ($1, $2, $3, $4, now())`,
_, err := s.db.Exec(`
INSERT INTO "subscribers"
("topic", "callback", "lease_seconds", "secret", "created")
VALUES ($1, $2, $3, $4, now())
ON CONFLICT ON CONSTRAINT subscribers_topic_callback
DO UPDATE SET lease_seconds = excluded.lease_seconds,
secret = excluded.secret,
updated = excluded.created
`,
topic,
sub.Callback,
sub.LeaseSeconds,

@ -0,0 +1 @@
ALTER TABLE "subscribers" ADD COLUMN "updated" TIMESTAMP NULL;
Loading…
Cancel
Save