-- name: CreateContact :exec
INSERT INTO contacts (id, tenant_id, account_id, name, email, phone, role_title, status, created_at, updated_at)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);

-- name: UpdateContact :exec
UPDATE contacts
SET account_id=$1, name=$2, email=$3, phone=$4, role_title=$5, status=$6, updated_at=$7
WHERE tenant_id=$8 AND id=$9;

-- name: GetContact :one
SELECT * FROM contacts WHERE tenant_id=$1 AND id=$2;

-- name: ListContacts :many
SELECT * FROM contacts WHERE tenant_id=$1 AND status <> 'archived' ORDER BY created_at DESC;

-- name: ArchiveContact :exec
UPDATE contacts SET status='archived', updated_at=$1 WHERE tenant_id=$2 AND id=$3;
