-- Additive only. Per-user roasting machines: uploaded .alogs attach to one, learning is
-- computed per roaster, and `overrides` stores the user's manual tweaks to what the learned
-- profile would otherwise apply to their plans (milestone temps, TP time, pace factor).
CREATE TABLE roasters (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  name text NOT NULL,
  model text NOT NULL DEFAULT '',
  notes text NOT NULL DEFAULT '',
  is_default boolean NOT NULL DEFAULT false,
  overrides jsonb NOT NULL DEFAULT '{}',
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX roasters_user ON roasters(user_id, created_at);
ALTER TABLE actual_roasts ADD COLUMN roaster_id uuid REFERENCES roasters(id) ON DELETE SET NULL;
CREATE INDEX actual_roasts_roaster ON actual_roasts(roaster_id);
