-- Adds an optional computed reading to a journal entry, captured the same
-- way the day tabs derive their headline number: peak value of the active
-- profile's main field across that day's hourly forecast rows. Only
-- possible for dates inside the 14-day forecast window, so it's nullable -
-- older/out-of-range entries stay note-only.

ALTER TABLE journal_entries
  ADD COLUMN profile       VARCHAR(32)     NULL AFTER note,
  ADD COLUMN reading       DECIMAL(5,1)    NULL AFTER profile,
  ADD COLUMN location_name VARCHAR(255)    NULL AFTER reading,
  ADD COLUMN lat           DECIMAL(8,5)    NULL AFTER location_name,
  ADD COLUMN lon           DECIMAL(8,5)    NULL AFTER lat;

INSERT IGNORE INTO schema_migrations (version) VALUES ('002_add_reading');
