-- Migration: add ai_analyses table
USE growlytics;

CREATE TABLE IF NOT EXISTS ai_analyses (
  id             INT AUTO_INCREMENT PRIMARY KEY,
  plant_id       INT NOT NULL,
  mode           VARCHAR(20) NOT NULL DEFAULT 'full',
  content        LONGTEXT NOT NULL,
  input_tokens   INT,
  output_tokens  INT,
  created_at     TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (plant_id) REFERENCES plants(id) ON DELETE CASCADE
) ENGINE=InnoDB;
