-- User health / wearable metrics (Apple Health style keys)
-- Run this once on your nobese database.

CREATE TABLE IF NOT EXISTS `user_health_metrics` (
  `health_metric_id` INT NOT NULL AUTO_INCREMENT,
  `user_id` INT NOT NULL,
  `blood_glucose` DECIMAL(12,4) DEFAULT NULL,
  `blood_oxygen` DECIMAL(12,4) DEFAULT NULL,
  `bloodpressure_diastolic` DECIMAL(12,4) DEFAULT NULL,
  `bloodpressure_systolic` DECIMAL(12,4) DEFAULT NULL,
  `body_fat_percentage` DECIMAL(12,4) DEFAULT NULL,
  `body_mass_index` DECIMAL(12,4) DEFAULT NULL,
  `heart_rate` DECIMAL(12,4) DEFAULT NULL,
  `resting_heart_rate` DECIMAL(12,4) DEFAULT NULL,
  `respiratory_rate` DECIMAL(12,4) DEFAULT NULL,
  `steps` DECIMAL(12,4) DEFAULT NULL,
  `walking_heart_rate` DECIMAL(12,4) DEFAULT NULL,
  `weight` DECIMAL(12,4) DEFAULT NULL,
  `distance_walking_running` DECIMAL(12,4) DEFAULT NULL,
  `flight_climbed` DECIMAL(12,4) DEFAULT NULL,
  `distance_delta` DECIMAL(12,4) DEFAULT NULL,
  `sleep_asleep` DECIMAL(12,4) DEFAULT NULL,
  `sleep_awake` DECIMAL(12,4) DEFAULT NULL,
  `sleep_awake_in_bed` DECIMAL(12,4) DEFAULT NULL,
  `sleep_deep` DECIMAL(12,4) DEFAULT NULL,
  `sleep_in_bed` DECIMAL(12,4) DEFAULT NULL,
  `sleep_light` DECIMAL(12,4) DEFAULT NULL,
  `sleep_out_of_bed` DECIMAL(12,4) DEFAULT NULL,
  `sleep_rem` DECIMAL(12,4) DEFAULT NULL,
  `sleep_unknown` DECIMAL(12,4) DEFAULT NULL,
  `sleep_session` TEXT DEFAULT NULL,
  `water` DECIMAL(12,4) DEFAULT NULL,
  `exercise_time` DECIMAL(12,4) DEFAULT NULL,
  `workout` TEXT DEFAULT NULL,
  `high_heart_rate_event` TEXT DEFAULT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`health_metric_id`),
  UNIQUE KEY `uniq_user_health_metrics_user_id` (`user_id`),
  KEY `idx_user_health_metrics_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
