ALTER TABLE agencies
  ADD COLUMN avatar VARCHAR(512) NOT NULL DEFAULT '' COMMENT '公会头像' AFTER name;

UPDATE agencies a
JOIN users u
  ON u.app_code = a.app_code AND u.user_id = a.owner_user_id
SET a.avatar = COALESCE(u.avatar, '')
WHERE a.avatar = '';
