-- Migration script to add missing columns to group table
-- Adds user_ids and description columns

DO $$
BEGIN
  -- Add user_ids column if it doesn't exist
  IF NOT EXISTS (
    SELECT 1 
    FROM information_schema.columns 
    WHERE table_name = 'group' 
      AND column_name = 'user_ids'
  ) THEN
    ALTER TABLE "group" 
    ADD COLUMN user_ids TEXT;
    
    RAISE NOTICE 'Added user_ids column to group table';
  ELSE
    RAISE NOTICE 'user_ids column already exists in group table';
  END IF;

  -- Add description column if it doesn't exist
  IF NOT EXISTS (
    SELECT 1 
    FROM information_schema.columns 
    WHERE table_name = 'group' 
      AND column_name = 'description'
  ) THEN
    ALTER TABLE "group" 
    ADD COLUMN description TEXT;
    
    RAISE NOTICE 'Added description column to group table';
  ELSE
    RAISE NOTICE 'description column already exists in group table';
  END IF;
END $$;