LPS-34574 Upgrading Image Gallery to 6.1: permissions for images and image folders are not properly upgraded USING SHARDING

During an upgrade process we can not call services so we have to set the proper database before run the SQL