ALTER TABLE accounts ADD COLUMN folder_mapping JSONB NOT NULL DEFAULT '{}'; ALTER TABLE accounts ADD COLUMN excluded_folders JSONB NOT NULL DEFAULT '[]'; -- Carry the existing task-wide mapping onto its accounts so behavior is preserved. UPDATE accounts a SET folder_mapping = t.folder_mapping FROM tasks t WHERE a.task_id = t.id AND t.folder_mapping <> '{}'::jsonb;