Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Removal of migration scripts on each new version
byHi, although at first I thought it was a good idea to keep the migration scripts, I now believe there are stronger reasons not to.
Recently, I was working on a migration from version 12 to 16 of an Odoo Enterprise database with a significant number of OCA modules.
I’ve built a small script that collects all the relevant migration scripts based on a CSV file specifying the installed modules and the URL of the corresponding OCA repositories:
👉 https://github.com/javierjcf/odoo-mig-analyzer
The script is just an initial idea — it takes the list of installed modules from a CSV and generates .txt
and .csv
files grouped by repository, listing the modules that contain migrations. It can also save these into a directory, which makes analysis easier. However, it’s still necessary to manually build a script that performs the specific migration actions you need from each of them.
The idea is to take the migrated database returned by Odoo, then run a script in odoo shell
that executes the necessary migration scripts for your project. After that, you perform an update all
to trigger the final version’s migrations, ensuring all prior scripts were executed.
The problem: When trying to launch odoo shell
, you often encounter errors that require running a first update all
, which upgrades the OCA modules to version 16—potentially skipping or breaking some migration scripts that should have run earlier. Also, some scripts may rely on code from the original version, making them incompatible at this stage.
At this point, the process seems too unreliable. One workaround I considered was running everything directly in SQL, but that could become quite complex depending on the module.
Right now, I think it’s more practical to use OpenUpgrade to migrate the Enterprise database. Then, manually write scripts to handle the Enterprise modules in use—at least in our case, OCA modules far outnumber the Enterprise ones.
There really doesn’t seem to be a reliable migration process for Enterprise databases with many OCA modules. The fact that you can’t reliably run all the migration scripts at the correct version steps makes the entire process fragile.
Does anyone have any ideas on how to make this process more reliable?
Hmm,
I would argue the opposite. It is rare that a migration is dangerous to leave in. If a cetain feature is deprectated in the future that makes the migration irrelevant or wrong, then it needs to be adjusted or taken out.
But if something needs to be populated if going from 16.0.0 -> 16.0.1, then by extension, it is almost certainly needed if going from 14 -> 18....
I think part of making changes and adding features is writing relevant migrations, and checking that other migrations are still relevant.
From: Enric Tobella Alomar <notifications@odoo-community.org>
Sent: Wednesday, 7 May 2025 8:52 PM
To: Contributors <contributors@odoo-community.org>
Subject: Re: Removal of migration scripts on each new versionI prefer to remove the scripts.
The reason is simple, it is safer.
Keeping them might work in some cases, but it might be problematic in others. It is true that as a community, we don't want to make life harder for community or enterprise developers. However, our duty is to deliver the safest option.
We cannot ask a developer to take into account if this change might affect when coming from 12 or 13 or 14 or.... it is easier to take into account just the current version.
I understand that in some specific cases, with a strong maintainer behind the project, it might have sense, but not as a rule.
Also, with the latest versions (with the scripts folder) it might be easy to create an aggregator of scripts. If you want, we can do a work table on this topic on the next OCA Days (On Belgium or in Spain)
My 2 cents.
El mié, 7 may 2025 a las 12:27, Sebastien Alix (<notifications@odoo-community.org>) escribió:
Hello,
Overall I tend to agree with Pedro on this topic. At C2C we are often jumping 2 to 4 versions when migrating a database, so we are not migrating version by version regarding OCA modules (it would take too much time), and by experience:
- often `pre` scripts can run without adaptation (that could happen of course with all reasons written by Pedro above), as they normally only rely on SQL
- `post` ones that are using Odoo ORM can be broken easily (i.e. invoking a 16.0 post script with an 18.0 Odoo code base), and therefore requires modifications (making such script idempotent will require extra work from contributors if we go that way)
To ease the migration work, we are starting to use a tool that reports all intermediate migration scripts for a given module (things start to be complicated when a module is renamed/changed repo but it's another story), and we check which one is relevant for the migration. After that we consolidate these migration scripts (copy/paste + some adaptations) locally in the project.
=> often, some migration scripts could be avoided, and we keep only ones that make sense for the migration. I do not have exact figures but if we have let's say 4 migration scripts for a module from 14.0 to 18.0, often we land with only 1 or 2 that are relevant and could ignore remaining ones.
=> from what I see currently in our biggest projects jumping 4 versions, modules impacted by these intermediate migration scripts represent less than 10% of installed OCA modules
=> its easier/faster for us to get these info before we start a migration and consolidate scripts manually afterwards, than ensuring every intermediate migration scripts will be idempotent to ensure versions jump. It's not perfect, but that works...
Note: Pushing this tool in community is complicated for now (for different reasons, and we are lacking of time, things still need to be discussed), but I would like to see that happening later one way or another to consolidate community knowledge and contributions (but this is another topic than the one discussed here).
That said, I'm not against keeping some of these scripts if it makes life easier, like the one for `queue_job`, but by default it's easier to drop them IMO, and during review maintainers could state if it deserves to be kept?
Le 06/05/2025 à 13:02, Stefan Rijnhart a écrit :
Hi,
the migration guide mandates the following
> Remove any possible migration script from previous version (in a nutshell, removemigrations
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_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
-- Sébastien Alix Business Solutions Odoo Developer Camptocamp France SA https://www.camptocamp.com/_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
--
Enric Tobella AlomarCEO & Founder
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
Reference
-
Removal of migration scripts on each new version
byOpener B.V., Stefan Rijnhart-
Re: Removal of migration scripts on each new version
byComunitea, Javier Colmenero Fernández -
Re: Removal of migration scripts on each new version
by "Richard deMeester" <richard.demeester@willdooit.com> - 07/05/2025 15:49:29 - 12 -
Re: Removal of migration scripts on each new version
byOpener B.V., Stefan Rijnhart -
Re: Removal of migration scripts on each new version
byDIXMIT Consulting SLU, Enric Tobella Alomar -
Re: Removal of migration scripts on each new version
byCamptocamp France SAS, Sébastien Alix -
Re: Removal of migration scripts on each new version
byAcsone SA/NV, Stéphane Bidoul -
Re: Removal of migration scripts on each new version
bySygel Technology S.L., Valentín Vinagre -
Re: Removal of migration scripts on each new version
byAkretion France., Raphaël Reverdy -
Re: Removal of migration scripts on each new version
byTherp, Tom Blauwendraat -
Re: Removal of migration scripts on each new version
byMoaHub, Graeme Gellatly
-