-- Lets each of the 4 SMS triggers (mortality, feed_reorder, sale_receipt,
-- vaccination_due) be independently turned off and given its own custom
-- wording, configured per farm on the Configurations page. Sits underneath
-- the existing general "SMS alerts" toggle in Settings, which still gates
-- all of them. No row for a (farm, kind) pair means "enabled, built-in
-- default wording" — see Sms::triggerConfig().
CREATE TABLE IF NOT EXISTS sms_triggers (
  id            INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
  farm_id       INT UNSIGNED  NOT NULL,
  kind          VARCHAR(30)   NOT NULL,
  enabled       TINYINT(1)    NOT NULL DEFAULT 1,
  message       VARCHAR(500)  NULL,
  created_at    TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at    TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uq_sms_trigger_farm_kind (farm_id, kind),
  CONSTRAINT fk_sms_trigger_farm FOREIGN KEY (farm_id) REFERENCES farms(id) ON DELETE CASCADE
) ENGINE=InnoDB;
