-- Migration: 47_messages.up.sql

UPDATE public.messages
SET message = ''
WHERE message IS NULL;

ALTER TABLE IF EXISTS public.messages
    ALTER COLUMN message SET NOT NULL;

ALTER TABLE IF EXISTS public.messages
ADD COLUMN IF NOT EXISTS reply_to_id UUID REFERENCES messages(messageid) ON DELETE SET NULL,
ADD COLUMN IF NOT EXISTS is_forwarded BOOLEAN NOT NULL DEFAULT FALSE;