Unable to restore/update discourse (PG::InvalidTextRepresentation: ERROR: invalid input syntax for type integer: "[]")

I think you should be able to run SiteSetting.selectable_avatars = "" (from the rails console again), and then be good for a rebuild.