# Set the lowest ID as the new_id, and collect other IDs to update/delete
new_id=users[0].id
old_ids=[user.idforuserinusers[1:]]
print(profile_id)
ifold_ids:
# Update tables with batch IN clause
conn.execute(text('UPDATE "post" SET community_id = :new_id WHERE community_id IN :old_ids'),{"new_id":new_id,"old_ids":tuple(old_ids)})
conn.execute(text('UPDATE "post_reply" SET community_id = :new_id WHERE community_id IN :old_ids'),{"new_id":new_id,"old_ids":tuple(old_ids)})
conn.execute(text('UPDATE "report" SET suspect_community_id = :new_id WHERE suspect_community_id IN :old_ids'),{"new_id":new_id,"old_ids":tuple(old_ids)})
conn.execute(text('UPDATE "report" SET in_community_id = :new_id WHERE in_community_id IN :old_ids'),{"new_id":new_id,"old_ids":tuple(old_ids)})
conn.execute(text('UPDATE "mod_log" SET community_id = :new_id WHERE community_id IN :old_ids'),{"new_id":new_id,"old_ids":tuple(old_ids)})
conn.execute(text('DELETE FROM "community_block" WHERE community_id IN :old_ids'),{"old_ids":tuple(old_ids)})
conn.execute(text('DELETE FROM "community_member" WHERE community_id IN :old_ids'),{"old_ids":tuple(old_ids)})
conn.execute(text('DELETE FROM "community_ban" WHERE community_id IN :old_ids'),{"old_ids":tuple(old_ids)})
conn.execute(text('DELETE FROM "community_join_request" WHERE community_id IN :old_ids'),{"old_ids":tuple(old_ids)})