-- Incident types (Einsatzarten) for template filtering and organization-specific workflows

CREATE TABLE IF NOT EXISTS incident_type (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  key text NOT NULL UNIQUE,
  label text NOT NULL,
  description text,
  is_active boolean NOT NULL DEFAULT true,
  sort int NOT NULL DEFAULT 100,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz
);

ALTER TABLE incident
  ADD COLUMN IF NOT EXISTS incident_type_id uuid REFERENCES incident_type(id);

CREATE INDEX IF NOT EXISTS idx_incident_incident_type_id ON incident(incident_type_id);
