-- 023_custom_share_messages.sql
-- Idempotente : ADD COLUMN IF NOT EXISTS + DROP/ADD CONSTRAINT

ALTER TABLE users
  ADD COLUMN IF NOT EXISTS custom_share_message_client      TEXT,
  ADD COLUMN IF NOT EXISTS custom_share_message_ambassador   TEXT,
  ADD COLUMN IF NOT EXISTS share_msg_client_status          VARCHAR(20) NOT NULL DEFAULT 'approved',
  ADD COLUMN IF NOT EXISTS share_msg_ambassador_status      VARCHAR(20) NOT NULL DEFAULT 'approved';

ALTER TABLE users
  DROP CONSTRAINT IF EXISTS chk_share_msg_client_status;
ALTER TABLE users
  ADD CONSTRAINT chk_share_msg_client_status
    CHECK (share_msg_client_status IN ('pending_review', 'approved', 'blocked'));

ALTER TABLE users
  DROP CONSTRAINT IF EXISTS chk_share_msg_ambassador_status;
ALTER TABLE users
  ADD CONSTRAINT chk_share_msg_ambassador_status
    CHECK (share_msg_ambassador_status IN ('pending_review', 'approved', 'blocked'));
