cleanup updates with no vm reference
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-02 13:17:29 +10:00
parent f80dfe9027
commit 77c1928436
4 changed files with 34 additions and 17 deletions

View File

@@ -75,6 +75,11 @@ DELETE FROM "Updates"
WHERE "UpdateType" = sqlc.arg('updateType') AND "UpdateTime" <= sqlc.arg('updateTime')
RETURNING *;
-- name: CleanupUpdatesNullVm :exec
DELETE FROM "Updates"
WHERE "InventoryId" IS NULL
RETURNING *;
-- name: CreateEvent :one
INSERT INTO "Events" (
"CloudId", "Source", "EventTime", "ChainId", "VmId", "VmName", "EventType", "EventKey", "DatacenterId", "DatacenterName", "ComputeResourceId", "ComputeResourceName", "UserName"

View File

@@ -26,6 +26,17 @@ func (q *Queries) CleanupUpdates(ctx context.Context, arg CleanupUpdatesParams)
return err
}
const cleanupUpdatesNullVm = `-- name: CleanupUpdatesNullVm :exec
DELETE FROM "Updates"
WHERE "InventoryId" IS NULL
RETURNING Uid, InventoryId, UpdateTime, UpdateType, NewVcpus, NewRam, NewResourcePool, EventKey, EventId, NewProvisionedDisk, UserName, PlaceholderChange, Name
`
func (q *Queries) CleanupUpdatesNullVm(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, cleanupUpdatesNullVm)
return err
}
const createEvent = `-- name: CreateEvent :one
INSERT INTO "Events" (
"CloudId", "Source", "EventTime", "ChainId", "VmId", "VmName", "EventType", "EventKey", "DatacenterId", "DatacenterName", "ComputeResourceId", "ComputeResourceName", "UserName"