sqlinsight-pro/src/SQLInsight.Repository/Migrations/0012_support_close.sql
Søren Eggert Lundsteen Olsen f3551b1bf0 Support cases through the API: create, read and close
- POST/GET /api/v1/support-cases[/{id}] and POST .../{id}/close in
  SQLInsight Web, sharing the /support form's logic: same checks, finding
  prefill without sensitive evidence, Idempotency-Key as the request id,
  202 Accepted with Location, problem+json 403 without the support:write
  scope or a support license. RequestedBy is the Windows user or
  token:<name>.
- Closing: "Luk sag" on /support and the API record CloseRequested
  (migration 0012, column-level UPDATE for the read-only web login); the
  agent sends it to the hub with backoff and sets Closed when confirmed;
  a pending case is closed once it has a number; an older hub list never
  turns CloseRequested back to Open.
- Hub: POST /api/v1/cases/{reference}/close for the license's own cases
  (others 404), idempotent, ClosedBy/ClosedComment (EF migration
  CaseClosedBy). Portal closing records "SEOSoft: <user>"; the customer
  page shows who closed and why; the support report and CSV get "Lukket af".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 09:47:58 +02:00

16 lines
1.1 KiB
Transact-SQL

/* Closing support cases from SQLInsight Web (the /support page or POST /api/v1/support-cases/{id}/close): the web
UI records the request, the agent sends it to SQLInsight Hub and sets Closed when the hub has confirmed it. A request
on a case without a number yet is sent once the hub has created the case. */
ALTER TABLE insight.SupportCases ADD
CloseRequestedAt datetime2(0) NULL,
CloseRequestedBy nvarchar(256) NULL,
CloseComment nvarchar(1000) NULL,
CloseAttempts int NOT NULL CONSTRAINT DF_SupportCases_CloseAttempts DEFAULT (0),
CloseNextAttemptAt datetime2(0) NULL,
ClosedBy nvarchar(300) NULL;
GO
ALTER TABLE insight.SupportCases DROP CONSTRAINT CK_SupportCases_Status;
ALTER TABLE insight.SupportCases ADD CONSTRAINT CK_SupportCases_Status CHECK (Status IN ('Pending', 'Open', 'CloseRequested', 'Closed', 'Failed'));
GO
/* Like INSERT in 0005: the web UI may record a close request on these columns only. */
GRANT UPDATE ON insight.SupportCases (CloseRequestedAt, CloseRequestedBy, CloseComment, CloseNextAttemptAt, Status, UpdatedAt) TO public;