Structs and Upgradeable Safe contracts

Hello i’m curious about adding new structs into a contract after deploying.

I see upgradeable safe documentation mentions only variables are affected when upgrading, so does this mean we can upgrade our contract with a new struct, and use that new struct with a new mapping variable such as the follow

contract A {
     struct X {
         uint256 Z
     }

     mapping(address => X) public myVar1;
}

After upgrade

contract A {
     struct X {
         uint256 Z
     }
     struct Y {
         uint256 Z
     }


     mapping(address => X) public myVar1;
     mapping(address => Y) public myVar2;
}

Is this considered upgrade safe?

1 Like

There is an article about this, maybe it can give you some idea. https://blog.openzeppelin.com/the-state-of-smart-contract-upgrades

2 Likes

The post shared by @Skyge is excellent. You can also check the official documentation on storage changes.

1 Like