Is it safe to change storage variables visibility + remove initialize function in an upgrade?

Hi @bugduino,

When upgrading we can’t change the order nor the type of state variables (https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts).

Removing functions is fine. You need to keep the inheritance of Initializable as it contains a state variable.

Changing a state variable visibility shouldn’t be an issue as you aren’t changing the order or the type.
The same goes for decoupling storage, though you need to watch out for the order that you extend the contracts, so you are adding AStorage last and keeping the order of the state variables when the contract is linearized. (Solidity Diamond Inheritance)

I recommend thorough testing. The OpenZeppelin Upgrades Plugins can be a good way to do this and I have an example showing testing the upgrade:

With your upgrade function manualInitialize you are protecting it with onlyOwner. You may want to include logic to ensure it is only called once, such as checking the state of a variable, otherwise the owner should call this multiple times.