-- name: AddProviderState :exec
INSERT INTO core.provider_states (provider, state)
VALUES ($1, $2)
ON CONFLICT (provider, state) DO NOTHING;

-- name: ListProviderStates :many
SELECT state FROM core.provider_states
WHERE provider = $1 ORDER BY state;

-- name: ListAllProviderStates :many
SELECT provider, state FROM core.provider_states
ORDER BY provider, state;

-- name: DeleteProviderStatesNotIn :exec
-- Boot reconciliation: drop states a provider no longer declares.
DELETE FROM core.provider_states
WHERE provider = $1 AND state <> ALL(@states::text[]);
