-- name: ListInventory :many
SELECT * FROM "Inventory"
ORDER BY "Name";

-- name: GetInventoryByName :many
SELECT * FROM "Inventory"
WHERE "Name" = ?;

-- name: GetInventoryVmId :one
SELECT * FROM "Inventory"
WHERE "VmId" = ? LIMIT 1;

-- name: GetInventoryEventId :one
SELECT * FROM "Inventory"
WHERE "EventId" = ? LIMIT 1;

-- name: CreateInventory :one
INSERT INTO "Inventory" (
    "Name", "Vcenter", "VmId", "EventKey", "EventId", "CreationTime", "ResourcePool", "VmType", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", "InitialRam", "SrmPlaceholder"
) VALUES(
    ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
RETURNING *;

-- name: CreateUpdate :one
INSERT INTO "Updates" (
    "InventoryId", "EventKey", "EventId", "UpdateTime", "UpdateType", "NewVcpus", "NewRam", "NewResourcePool"
) VALUES(
    ?, ?, ?, ?, ?, ?, ?, ?
)
RETURNING *;