V3 version with backward comp

This commit is contained in:
m
2026-07-28 18:12:56 +02:00
parent 7713835739
commit bd6e7c38f9
48 changed files with 3685 additions and 1344 deletions
@@ -0,0 +1,32 @@
-- name: CreatePlacement :one
INSERT INTO resource_placements (resource_id, storage_location_id, status, storage_key, synced_at)
VALUES ($1, $2, $3, $4, $5)
RETURNING *;
-- name: GetPlacement :one
SELECT * FROM resource_placements
WHERE resource_id = $1 AND storage_location_id = $2
LIMIT 1;
-- name: ListPlacementsByResource :many
SELECT * FROM resource_placements
WHERE resource_id = $1;
-- name: ListPlacementsByLocation :many
SELECT * FROM resource_placements
WHERE storage_location_id = $1;
-- name: UpdatePlacementStatus :exec
UPDATE resource_placements
SET status = $1, synced_at = CURRENT_TIMESTAMP
WHERE id = $2;
-- name: DeletePlacement :exec
DELETE FROM resource_placements
WHERE id = $1;
-- name: GetServerPlacementByResource :one
SELECT rp.* FROM resource_placements rp
JOIN storage_locations sl ON sl.id = rp.storage_location_id
WHERE rp.resource_id = $1 AND sl.role = 'server'
LIMIT 1;