add code to handle deletion event
This commit is contained in:
@@ -22,6 +22,11 @@ INSERT INTO "Inventory" (
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: InventoryMarkDeleted :exec
|
||||
UPDATE "Inventory"
|
||||
SET "DeletionTime" = sqlc.arg('deletionTime')
|
||||
WHERE "VmId" = sqlc.arg('vmId') AND "Datacenter" = sqlc.arg('datacenterName');
|
||||
|
||||
-- name: CreateUpdate :one
|
||||
INSERT INTO "Updates" (
|
||||
"InventoryId", "EventKey", "EventId", "UpdateTime", "UpdateType", "NewVcpus", "NewRam", "NewResourcePool"
|
||||
|
@@ -302,6 +302,23 @@ func (q *Queries) GetInventoryVmId(ctx context.Context, vmid sql.NullString) (In
|
||||
return i, err
|
||||
}
|
||||
|
||||
const inventoryMarkDeleted = `-- name: InventoryMarkDeleted :exec
|
||||
UPDATE "Inventory"
|
||||
SET "DeletionTime" = ?1
|
||||
WHERE "VmId" = ?2 AND "Datacenter" = ?3
|
||||
`
|
||||
|
||||
type InventoryMarkDeletedParams struct {
|
||||
DeletionTime sql.NullInt64
|
||||
VmId sql.NullString
|
||||
DatacenterName sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) InventoryMarkDeleted(ctx context.Context, arg InventoryMarkDeletedParams) error {
|
||||
_, err := q.db.ExecContext(ctx, inventoryMarkDeleted, arg.DeletionTime, arg.VmId, arg.DatacenterName)
|
||||
return err
|
||||
}
|
||||
|
||||
const listEvents = `-- name: ListEvents :many
|
||||
SELECT Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName, EventType FROM "Events"
|
||||
ORDER BY "EventTime"
|
||||
|
Reference in New Issue
Block a user