-- Adds D&D Beyond sync columns to the characters table.
ALTER TABLE characters ADD COLUMN dndbeyond_id TEXT;
ALTER TABLE characters ADD COLUMN dndbeyond_last_sync TEXT;

-- Prevent two entries for the same DnD Beyond character ID within the same campaign
CREATE UNIQUE INDEX IF NOT EXISTS idx_characters_dndbeyond
  ON characters(campaign_id, dndbeyond_id) WHERE dndbeyond_id IS NOT NULL;
