ESP32 "The program size is greater than maximum allowed"

I have these partitions

factory,  app,  factory,        ,512K,
ota_0,    app,  ota_0,          , 1332K,
ota_1,    app,  ota_1,          ,1332K,

and I have a custom upload script that uploads the built program firmware (the actual firmware that gets compiled and would normally be uploaded to factory) to ota_0. However because PlatformIO thinks it has to upload the firmware to factory, it throws an error that the factory partition is too small for the firmware, when in reality my upload script would upload the firmware to ota_0, which is big enough.

How do I tell PlatformIO to ignore the size mismatch?

Oh, and also my custom upload script uploads a different firmware to factory.

There seems to be a feature that is not documented, where you can specify your target partition.

If not set (default), it will use the the first partition in the list whose name is either factory or ota_0. Since factory appears first in your partitions, it will take factory.

But set

board_build.app_partition_name = ota_0

in the platformio.ini and it should now fetch the maximum size from ota_0.