feat(api): add /v1/maintenance policies and run endpoints
OpenAPI, httpapi CRUD/run/dry-run, job maintenance_policy_run и audit с policy_id. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -82,12 +82,17 @@ func RunCleanup(ctx context.Context, pool *pgxpool.Pool, policy string, dryRun b
|
||||
|
||||
// InsertMaintenanceAudit records an audit row at job start.
|
||||
func InsertMaintenanceAudit(ctx context.Context, pool *pgxpool.Pool, tenantID, actorPrefix, kind, table string, dryRun bool) (string, error) {
|
||||
return InsertMaintenanceAuditWithPolicy(ctx, pool, tenantID, actorPrefix, kind, table, "", dryRun)
|
||||
}
|
||||
|
||||
// InsertMaintenanceAuditWithPolicy records an audit row linked to maintenance_policy.
|
||||
func InsertMaintenanceAuditWithPolicy(ctx context.Context, pool *pgxpool.Pool, tenantID, actorPrefix, kind, table, policyID string, dryRun bool) (string, error) {
|
||||
id := uuid.New().String()
|
||||
_, err := pool.Exec(ctx, `
|
||||
INSERT INTO postgres_maintenance_audit
|
||||
(id, tenant_id, actor_prefix, kind, target_table, dry_run, status, created_at)
|
||||
VALUES ($1, NULLIF($2,''), NULLIF($3,''), $4, NULLIF($5,''), $6, 'running', now())`,
|
||||
id, tenantID, actorPrefix, kind, table, dryRun)
|
||||
(id, tenant_id, actor_prefix, kind, target_table, policy_id, dry_run, status, created_at)
|
||||
VALUES ($1, NULLIF($2,''), NULLIF($3,''), $4, NULLIF($5,''), NULLIF($6,''), $7, 'running', now())`,
|
||||
id, tenantID, actorPrefix, kind, table, policyID, dryRun)
|
||||
return id, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user