-- Migration 137: Add priority field to SAG module
-- Matches TTicket priority system for consistency

-- Create priority enum type
DO $$ BEGIN
    CREATE TYPE sag_priority AS ENUM ('low', 'normal', 'high', 'urgent');
EXCEPTION
    WHEN duplicate_object THEN null;
END $$;

-- Add priority column to sag_sager
ALTER TABLE sag_sager 
  ADD COLUMN IF NOT EXISTS priority sag_priority DEFAULT 'normal';

-- Add index for filtering by priority
CREATE INDEX IF NOT EXISTS idx_sag_priority ON sag_sager(priority);

-- Add comment for documentation
COMMENT ON COLUMN sag_sager.priority IS 'Case priority level: low, normal (default), high, urgent';
