2022-10-17 08:43:30 -05:00
|
|
|
-- name: GetReplicasUpdatedAfter :many
|
|
|
|
|
SELECT * FROM replicas WHERE updated_at > $1 AND stopped_at IS NULL;
|
|
|
|
|
|
2023-07-26 09:21:04 -07:00
|
|
|
-- name: GetReplicaByID :one
|
|
|
|
|
SELECT * FROM replicas WHERE id = $1;
|
|
|
|
|
|
2022-10-17 08:43:30 -05:00
|
|
|
-- name: InsertReplica :one
|
|
|
|
|
INSERT INTO replicas (
|
|
|
|
|
id,
|
|
|
|
|
created_at,
|
|
|
|
|
started_at,
|
|
|
|
|
updated_at,
|
|
|
|
|
hostname,
|
|
|
|
|
region_id,
|
|
|
|
|
relay_address,
|
|
|
|
|
version,
|
2023-07-26 09:21:04 -07:00
|
|
|
database_latency,
|
2026-06-24 15:04:04 -04:00
|
|
|
"primary",
|
|
|
|
|
cluster_host,
|
|
|
|
|
nats_port
|
|
|
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *;
|
2022-10-17 08:43:30 -05:00
|
|
|
|
|
|
|
|
-- name: UpdateReplica :one
|
|
|
|
|
UPDATE replicas SET
|
|
|
|
|
updated_at = $2,
|
|
|
|
|
started_at = $3,
|
|
|
|
|
stopped_at = $4,
|
|
|
|
|
relay_address = $5,
|
|
|
|
|
region_id = $6,
|
|
|
|
|
hostname = $7,
|
|
|
|
|
version = $8,
|
|
|
|
|
error = $9,
|
2023-07-26 09:21:04 -07:00
|
|
|
database_latency = $10,
|
2026-06-24 15:04:04 -04:00
|
|
|
"primary" = $11,
|
|
|
|
|
cluster_host = $12,
|
|
|
|
|
nats_port = $13
|
2022-10-17 08:43:30 -05:00
|
|
|
WHERE id = $1 RETURNING *;
|
|
|
|
|
|
|
|
|
|
-- name: DeleteReplicasUpdatedBefore :exec
|
|
|
|
|
DELETE FROM replicas WHERE updated_at < $1;
|