Files
wp-healthcheck/server/migrations/0003_archive.sql
T
steveandClaude Opus 4.8 85b4edc4f2 Dashboard: archive healthchecks + Archived section on homepage (hc-b8r)
Some audits are no longer needed. Add an archive toggle so they can be filed
away without deleting the history.

- Migration 0003 adds healthchecks.archived (INTEGER 0/1, NOT NULL DEFAULT 0
  — portable across MySQL/SQLite).
- Per-site page (/dashboard?site=X): each session row gets an Archive /
  Unarchive button and archived rows carry a muted "archived" badge.
- Home page: archived healthchecks are gathered under an "Archived" heading
  at the foot, each with an Unarchive button.
- POST /dashboard/healthchecks/{id}/archive, mirroring the reopen flow:
  session-cookie auth + CSRF token. archived=1 archives, else un-archives.
  The redirect-back target is validated to a same-origin /dashboard path
  (no open-redirect / header injection).
- setArchived() deliberately leaves updated_at alone, so filing a session
  doesn't jump its site to the top of the dashboard ordering.
- Archived items are NOT hidden from their normal listings, per the request.

Dashboard-only; not exposed through the plugin API. 7 new tests (49 total).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-24 12:02:58 +01:00

13 lines
658 B
SQL

-- Archive flag for healthchecks the technician no longer needs surfaced.
--
-- Boolean stored as INTEGER 0/1 (portable: MySQL has no native BOOLEAN, it's a
-- TINYINT alias, and SQLite has no boolean type at all — both store 0/1 in an
-- INTEGER column). NOT NULL DEFAULT 0 so every existing row is "not archived"
-- and SQLite's ALTER TABLE ADD COLUMN is satisfied (it requires a default for a
-- NOT NULL column).
--
-- Archived rows are NOT hidden from their normal listings for now; the dashboard
-- just additionally gathers them under an "Archived" heading on the home page.
ALTER TABLE healthchecks ADD COLUMN archived INTEGER NOT NULL DEFAULT 0;