ALTER TABLE note_revisions ADD COLUMN collaboration_client_id TEXT;
ALTER TABLE note_revisions ADD COLUMN collaboration_update_id INTEGER;
CREATE UNIQUE INDEX IF NOT EXISTS idx_note_revisions_collaboration_update
    ON note_revisions(note_id, collaboration_client_id, collaboration_update_id)
    WHERE collaboration_client_id IS NOT NULL AND collaboration_update_id IS NOT NULL;

ALTER TABLE revisions ADD COLUMN collaboration_client_id TEXT;
ALTER TABLE revisions ADD COLUMN collaboration_update_id INTEGER;
CREATE UNIQUE INDEX IF NOT EXISTS idx_revisions_collaboration_update
    ON revisions(pad_id, collaboration_client_id, collaboration_update_id)
    WHERE collaboration_client_id IS NOT NULL AND collaboration_update_id IS NOT NULL;
