If UpgradeSchema/UpgradeData
are executed when installing and upgrading a module what's the point of having InstallSchema/InstallData
(besides just having a well-named file that is only executed once). We could handle the install part in the Upgrade file as well - we could check !$context->getVersion()
.
This raises another question about the correct workflow for the lifetime of a module.
Do we create the Install* script only once and then never change it? I've seen third party modules changing this file between versions. In that case I assume they also track the same changes in Upgrade* (hence duplicating code).
Am I missing something here? Thanks!
UPDATE: I understand the role of each file and the differences between Schema and Data. I'm interested to find out about best practices. My understanding is we're allowed to update Install* as long as the module is in development but once it's made public we're not allowed to change this file ever again. From that point on we should only use versioned Upgrade* scripts. Is this correct?