17 lines
726 B
SQL
17 lines
726 B
SQL
-- name: CreateAccount :exec
|
|
INSERT INTO accounts (id, tenant_id, name, legal_name, document, website, industry, size, status, external_refs, created_at, updated_at)
|
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);
|
|
|
|
-- name: UpdateAccount :exec
|
|
UPDATE accounts
|
|
SET name=$1, legal_name=$2, document=$3, website=$4, industry=$5, size=$6, status=$7, external_refs=$8, updated_at=$9
|
|
WHERE tenant_id=$10 AND id=$11;
|
|
|
|
-- name: GetAccount :one
|
|
SELECT * FROM accounts WHERE tenant_id=$1 AND id=$2;
|
|
|
|
-- name: ListAccounts :many
|
|
SELECT * FROM accounts WHERE tenant_id=$1 AND status <> 'archived' ORDER BY created_at DESC;
|
|
|
|
-- name: ArchiveAccount :exec
|
|
UPDATE accounts SET status='archived', updated_at=$1 WHERE tenant_id=$2 AND id=$3;
|