-- Public, human-friendly changelog for the site itself.
--
-- Fits the "agentic website" thesis: the site documents its own evolution, and
-- an agent can append a row here as part of shipping a change. Same JSON-free,
-- flat shape the rest of the cja_* tables use — this is a log, not a graph.
--
-- `type` is a small closed set, so an ENUM is correct here (unlike the contact
-- subject, which grows). `entry_at` is the event time shown to readers; the row
-- timestamps are for bookkeeping.

CREATE TABLE IF NOT EXISTS `cja_changelog` (
  `changelog_id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `type`       enum('added','updated','fixed','bug','removed','note')
                             NOT NULL DEFAULT 'added',
  `summary`    varchar(255) NOT NULL,
  `detail`     varchar(500) DEFAULT NULL,

  `entry_at`   datetime     NOT NULL,   -- when the change happened
  `published`  tinyint(1)   NOT NULL DEFAULT 1,

  `created_at` datetime     NOT NULL DEFAULT current_timestamp(),

  PRIMARY KEY (`changelog_id`),
  KEY `idx_cja_changelog_feed` (`published`, `entry_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
