Yes, I’ve just realized that and edited my post accordingly.
I think utilizing the PostLocker from the console would be good, it also creates the staff log action.
Post.where(id: <pid>).find_each do |post|
locker = PostLocker.new(post, Discourse.system_user)
locker.lock
end