Skip to Content

Contributors

Re: Removal of migration scripts on each new version

On 06-05-2025 14:17, Juan José Scarafía wrote:

> I agree, keeping the migration scripts probably doesn't mean you can 

> just skip versions and expect them to run flawlessly, but in a lot of 

> cases, it does seem to work out just fine.

Well, they should run flawlessly otherwise it will break everyone's 
migration. The scripts that we keep should be idempotent and not be 
invalidated by subsequent data model changes. So special care should be 
taken when reviewing PRs that contain older scripts.


> On the other hand, I'm not really seeing any downside to leaving them 

> there. If you *are* updating version by version, those older scripts 

> just won't run anyway, right?

That is correct, if you migrate from 17 to 18, any 16.0.x.x.x migration 
script will not be triggered.



-- 
Opener B.V. - Business solutions driven by open source collaboration

Stefan Rijnhart - Consultant/developer

mail: stefan@opener.amsterdam
tel: +31 (0) 6 1447 8606
web: https://opener.amsterdam


by Stefan Rijnhart - 02:25 - 6 May 2025

Reference

  • Removal of migration scripts on each new version
    Hi,

    the migration guide mandates the following

    > Remove any possible migration script from previous version (in a nutshell, remove migrations folder inside the module if exists).

    (https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-18.0#tasks-to-do-in-the-migration)

    However, it is not uncommon to skip versions when migrating an Odoo instance. You would go from 15.0 or 16.0 to 18.0 rather than migrating every year. When using the Odoo enterprise migration, the migration scripts between the source and the target version are supposed to be present in the target version. So the migration guideline breaks this type of migration.

    I had a disagreement with Pedro Baeza about this on one PR, but I keep coming across instances of this such as https://github.com/OCA/account-invoicing/pull/1874 today so I would like to discuss this in a wider audience.

    My preference would be for the guideline to change to say that it is allowed to keep some of the scripts if they are safe for inclusion in the later version (such as the script from https://github.com/OCA/account-invoicing/pull/1874, which checks if a field already exists before trying to add it).

    Can I have a temperature check from the community to see how you all feel about this?

    Best regards,
    Stefan

    -- 
    Opener B.V. - Business solutions driven by open source collaboration
    
    Stefan Rijnhart - Consultant/developer
    
    mail: stefan@opener.amsterdam
    tel: +31 (0) 6 1447 8606
    web: https://opener.amsterdam

    by Stefan Rijnhart - 01:00 - 6 May 2025