Initializer use in upgraded contracts

Hello,

I am testing upgradable contracts and I am now trying to add a scenario where I first deploy a contract, change its state, then upgrade it to a new contract and check that the old state is not broken.

contract AV1 is Initializable {
     function initialize() public virtual initializer {
           // do stuff
     }
}

contract AV2 is A {
     function initialize() public override initializer {
          super.initialize(); 
          // do other stuff
     }
}

Then I execute the deployment and upgrade like this :

const AV1Factory = (await ethers.getContractFactory(
    "AV1",
    deployer
  )) as AV1__factory;

  av1Contract = (await upgrades.deployProxy(AV1Factory, {
    initializer: "initialize",
  })) as AV1;

 const AV2Factory = (await ethers.getContractFactory(
        "AV2"
 )) as AV2__factory;

 const aV2Contract = await upgrades.upgradeProxy(
        aV1Contract.address,
        AV2Factory
      );

What I realized (with logging) is that the initializer is never called during the upgrade process, neither V1 nor V2. On top, I see that there no way to specify an initializer for the V2 contract (assuming I would like to call it differently).

Could you please explain me what's the expected use of the initializer during the upgrade process? Am I missing something?

You are initializing the first one correctly, but it shouldn't be reinitialize for a second version or you would be returning the contract to the first state, in that case is not an upgrade but a new implementation.