Contributors mailing list archives

contributors@odoo-community.org

Avatar

Re: Migration Folders during migration in OCA Modules

by
Tecnativa. S. L., Pedro M. Baeza
- 15/07/2021 12:27:14
Yes, a pre-requisite is to have the previous version up to date before starting the migration, and if you run a migration across several versions in between, you have to manually launch the intermediate version scripts. It's what you have if you go through the enterprise path. I doubt Odoo performs all the migrations in one step, but it would be a version per version migration, but you only see the final result of the black box.

It's not possible to keep all the migration scripts across versions due to several reasons:

- "Logistic" one: keeping in sync such migration scripts across versions is a pain. If you perform a fix on v12 migration scripts, would you sincerely do the same patch on v13 and v14?
- And the main one: there are data transformations that aren't idempotent (for example, the renaming of a column), which means that running them several times will lead to errors. This combined with the pre/post/end mechanism, makes a non deterministic scenario where you will need to add a lot of control logic - or it will be directly impossible- to be handled across several versions. Example:

- On v12, you have 12.0.1.0.0 and 12.0.2.0.0 with scripts.
- On v13, you have 13.0.1.0.0 with scripts.

Migrating from v11 to v13, if all the scripts are in v13 (12.0.1.0.0, 12.0.2.0.0, 13.0.1.0.0 and 13.0.2.0.0), and you are not accessing v12 migration cycle, you will get this execution pipeline:

- Run 12.0.1.0.0 pre-migration
- Run 12.0.2.0.0 pre-migration
- Run 13.0.1.0.0 pre-migration
- Run 12.0.1.0.0 post-migration
- Run 12.0.2.0.0 post-migration
- Run 13.0.1.0.0 post-migration

Running with OpenUpgrade on each version, the execution pipeline is:

- Run 12.0.1.0.0 pre-migration
- Run 12.0.2.0.0 pre-migration
- Run 12.0.1.0.0 post-migration
- Run 12.0.2.0.0 post-migration
<new migration cycle>
- Run 13.0.1.0.0 pre-migration
- Run 13.0.1.0.0 post-migration

The only way is to manually re-create the same sequence. And this, expecting that there's no other dependent modules that perform operations on the expected pipeline.

More things to take into account: OCA module migration scripts are settled on expected renamed columns by OpenUpgrade, so we don't know how enterprise migration scripts are letting data, and thus, you will probably need to adapt existing migration scripts. Example: on the migration from 12 to 13, account.invoice model is merged with account.move. On OpenUpgrade, we created the columns `old_invoice_id` and `old_invoice_line_id` to link the previous record, and a lot of migration scripts rely on these columns for transferring information from old invoices to new moves.

Conclusion: I have resigned to use enterprise migration services, even on enterprise instances, and always do it through OpenUpgrade.

Regards.

Reference