-- name: ListIpProviders :many
SELECT * FROM ip_providers ORDER BY priority, id;

-- name: GetIpProvider :one
SELECT * FROM ip_providers WHERE id = ?;

-- name: CreateIpProvider :one
INSERT INTO ip_providers (url, name, enabled, priority)
VALUES (?, ?, ?, ?)
RETURNING *;

-- name: UpdateIpProvider :one
UPDATE ip_providers
SET url = ?, name = ?, enabled = ?, priority = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ?
RETURNING *;

-- name: DeleteIpProvider :exec
DELETE FROM ip_providers WHERE id = ?;

-- name: ListEnabledIpProviderUrls :many
SELECT url FROM ip_providers WHERE enabled = 1 ORDER BY priority, id;
