cleanup templates
Some checks failed
continuous-integration/drone/push Build is passing
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / End-to-End (push) Has been cancelled
CI / Publish Docker (push) Has been cancelled

This commit is contained in:
2024-10-02 21:23:54 +10:00
parent f9b8e25c2f
commit 9cdde0b278
3 changed files with 17 additions and 1 deletions

View File

@@ -58,6 +58,11 @@ DELETE FROM "Inventory"
WHERE "Vcenter" = sqlc.arg('vc') WHERE "Vcenter" = sqlc.arg('vc')
RETURNING *; RETURNING *;
-- name: InventoryCleanupTemplates :exec
DELETE FROM "Inventory"
WHERE "IsTemplate" = "TRUE"
RETURNING *;
-- name: CreateUpdate :one -- name: CreateUpdate :one
INSERT INTO "Updates" ( INSERT INTO "Updates" (
"InventoryId", "Name", "EventKey", "EventId", "UpdateTime", "UpdateType", "NewVcpus", "NewRam", "NewResourcePool", "NewProvisionedDisk", "UserName", "PlaceholderChange", "RawChangeString" "InventoryId", "Name", "EventKey", "EventId", "UpdateTime", "UpdateType", "NewVcpus", "NewRam", "NewResourcePool", "NewProvisionedDisk", "UserName", "PlaceholderChange", "RawChangeString"

View File

@@ -644,6 +644,17 @@ func (q *Queries) InventoryCleanup(ctx context.Context, arg InventoryCleanupPara
return err return err
} }
const inventoryCleanupTemplates = `-- name: InventoryCleanupTemplates :exec
DELETE FROM "Inventory"
WHERE "IsTemplate" = "TRUE"
RETURNING Iid, Name, Vcenter, VmId, EventKey, CloudId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, IsTemplate, PoweredOn, SrmPlaceholder, VmUuid
`
func (q *Queries) InventoryCleanupTemplates(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, inventoryCleanupTemplates)
return err
}
const inventoryCleanupVcenter = `-- name: InventoryCleanupVcenter :exec const inventoryCleanupVcenter = `-- name: InventoryCleanupVcenter :exec
DELETE FROM "Inventory" DELETE FROM "Inventory"
WHERE "Vcenter" = ?1 WHERE "Vcenter" = ?1

View File

@@ -26,7 +26,7 @@ func (h *Handler) UpdateCleanup(w http.ResponseWriter, r *http.Request) {
err := h.Database.Queries().CleanupUpdates(context.Background(), params) err := h.Database.Queries().CleanupUpdates(context.Background(), params)
*/ */
err := h.Database.Queries().CleanupUpdatesNullVm(context.Background()) err := h.Database.Queries().InventoryCleanupTemplates(context.Background())
if err != nil { if err != nil {
h.Logger.Error("Error received cleaning updates table", "error", err) h.Logger.Error("Error received cleaning updates table", "error", err)