Is it possible to have another initialize function that can be automatically called on when deploy for the subsequent versions of a contract?
For example, I may have the following first version:
contract MyContract is Initializable, UUPSUpgradeable {
string internal _name;
function initialize() public initializer {
_name = "Alice";
}
}
Then in my second version of my contract, I would like the _name
to be changed when it's being upgraded:
contract MyContractV2 is MyContract {
string internal _name;
function initialize() public initializer {
_name = "Bob";
}
}
The _name
wouldn't be changed in MyContractV2
because the initializer
has already been called before in the first version.
If I want the V2 of my contract to update certain variables or do certain things when deployed, how can I do that?