Skip to content
Odoo Upgrade

Technical Guide to Database Schema Changes in Odoo Version Upgrades

A practical guide for IT leaders and ERP consultants on managing database schema changes during Odoo version upgrades, covering risk assessment, migration strategies, and validation.

9 min readSysGenPro Editorial
Technical Guide to Database Schema Changes in Odoo Version Upgrades

Understanding Database Schema Changes in Odoo Upgrades

Upgrading Odoo involves more than updating application code; it requires careful management of underlying database schema changes. The recommended approach is to treat the database as a critical asset that must be migrated with the same rigor as the application itself. This process matters because Odoo evolves its data models, field types, and relationships between versions, which can break custom modules, integrations, and reporting if not handled correctly. The primary risks to control include data loss, broken foreign key constraints, incompatible custom fields, and downtime during the migration window. By understanding how Odoo handles schema evolution, IT leaders can plan a safer upgrade path that preserves data integrity and operational continuity.

Assessing Source and Target Version Compatibility

Before initiating any technical work, you must assess the compatibility between your current Odoo version and the target version. Odoo does not always support direct upgrades from older versions to the latest release. You must verify the official upgrade path supported by the Odoo community or enterprise team for your specific source and target versions. This assessment includes checking for deprecated modules, removed features, and significant architectural changes. For example, moving from Odoo 14 to Odoo 17 may involve intermediate steps or specific migration scripts that are not available for all version pairs. Always consult the official Odoo documentation for the exact versions involved, as compatibility claims can vary based on whether you are using Community or Enterprise editions.

Identifying Deprecated Features and Modules

A critical part of the assessment is identifying deprecated features and modules in your current installation. Odoo frequently removes or refactors modules between major versions. You should audit your installed modules list and cross-reference it with the target version's module repository. Modules that are no longer maintained or have been replaced by new implementations will need to be updated, replaced, or removed. This step is crucial because attempting to upgrade with incompatible modules can cause the migration process to fail or result in a broken system. Document all third-party add-ons and custom modules that may be affected, and contact their vendors to confirm compatibility with the target version.

Analyzing Custom Code and Module Dependencies

Custom code is the most common source of failure during Odoo upgrades. Your custom modules likely inherit from core Odoo models, views, and security rules that may have changed in the target version. You must perform a detailed dependency analysis to identify which custom modules depend on core models that have undergone schema changes. This includes checking for changes in field names, data types, and relationships. For instance, if a core field is renamed or its type is changed, any custom code that references that field will break. You should use static analysis tools to scan your custom code for deprecated API calls and model references. This analysis helps you prioritize which modules need to be rewritten or updated before the upgrade.

Mapping Model and Field Changes

To manage schema changes effectively, you need to map the differences between the source and target versions for all models used by your custom modules. This involves comparing the model definitions in both versions to identify added, removed, or modified fields. You can use database introspection tools to generate schema dumps for both versions and compare them. Pay special attention to fields that are used in business logic, reporting, or integrations. If a field is removed, you must determine how to handle the data stored in that field. Options include migrating the data to a new field, archiving it, or deleting it if it is no longer needed. This mapping exercise provides a clear picture of the technical work required to adapt your custom code to the new schema.

Preparing the Database for Migration

Database preparation is a critical step that ensures data integrity during the upgrade. You must create a full backup of your production database before starting any migration work. This backup should be tested for restore capability to ensure it is valid. Additionally, you should clean up unnecessary data, such as old logs, temporary files, or unused records, to reduce the size of the database and speed up the migration process. You should also check for data inconsistencies, such as orphaned records or broken foreign key references, and resolve them before the upgrade. A clean database reduces the risk of migration errors and makes it easier to identify issues that arise during the upgrade process.

Optimizing Database Performance

Database performance can impact the duration of the upgrade process. You should ensure that your PostgreSQL database is optimized for the migration workload. This includes checking for missing indexes, bloat in tables, and inefficient queries. You can use tools like pg_stat_statements to identify slow queries and optimize them. Additionally, you should ensure that your database server has sufficient resources, such as CPU, memory, and disk I/O, to handle the migration process. A well-optimized database can reduce the downtime required for the upgrade and improve the overall stability of the system after the upgrade.

Executing the Database Migration

The actual database migration involves running the Odoo upgrade scripts that modify the schema to match the target version. This process is typically automated by Odoo's upgrade mechanism, but it requires careful monitoring. You should run the migration in a staging environment first to identify any issues before applying it to production. During the migration, Odoo will apply schema changes, update data, and run post-migration scripts. You should monitor the logs for errors and warnings, and be prepared to intervene if the process fails. It is important to have a rollback plan in place in case the migration does not complete successfully. This plan should include restoring the database from the backup taken before the migration.

Handling Migration Errors

Migration errors can occur due to various reasons, such as incompatible custom code, data inconsistencies, or resource constraints. When an error occurs, you should analyze the error message to identify the root cause. Common errors include missing tables, invalid data types, or broken foreign key constraints. You should fix the underlying issue and re-run the migration process. If the error is related to custom code, you may need to update the code to be compatible with the new schema. If the error is related to data, you may need to clean up the data or adjust the migration scripts. It is important to document all errors and their resolutions to help with future upgrades.

Validating Data Integrity and System Functionality

After the migration is complete, you must validate the integrity of the data and the functionality of the system. This involves running a series of tests to ensure that all data has been migrated correctly and that all business processes are working as expected. You should compare the data in the new database with the data in the old database to ensure that no records have been lost or corrupted. You should also test critical business processes, such as creating sales orders, processing invoices, and generating reports. Additionally, you should test integrations with external systems to ensure that they are still working correctly. This validation step is crucial to ensure that the upgrade has not introduced any new issues.

Running Automated and Manual Tests

To ensure thorough validation, you should use a combination of automated and manual tests. Automated tests can be used to verify that the database schema is correct and that data has been migrated accurately. You can use tools to compare the schema of the new database with the expected schema and to check for data consistency. Manual tests are necessary to verify that business processes are working correctly and that users can interact with the system as expected. You should involve key users in the testing process to ensure that their specific needs are met. This combination of automated and manual tests provides a comprehensive validation of the upgraded system.

Planning Cutover and Rollback Strategies

Cutover planning is essential to minimize downtime and ensure a smooth transition to the new version. You should define a clear cutover plan that includes the steps to be taken, the roles and responsibilities of each team member, and the timeline for the cutover. You should also define go/no-go criteria that must be met before proceeding with the cutover. These criteria should include successful completion of all tests, resolution of all critical issues, and approval from key stakeholders. Additionally, you should have a rollback plan in place in case the cutover fails. This plan should include the steps to restore the system to its previous state and the criteria for triggering a rollback.

Defining Go/No-Go Criteria

Go/no-go criteria are the conditions that must be met before proceeding with the cutover. These criteria should be specific, measurable, and agreed upon by all stakeholders. Examples of go/no-go criteria include successful completion of all automated tests, resolution of all critical bugs, and approval from the project sponsor. You should document these criteria and communicate them to all team members. During the cutover, you should review the criteria and make a decision to proceed or roll back based on the status of the system. This approach helps to ensure that the cutover is only performed when the system is ready and reduces the risk of a failed upgrade.

Post-Upgrade Stabilization and Monitoring

After the upgrade is complete, you should enter a stabilization phase where you monitor the system for any issues that may arise. This phase is critical to ensure that the system is stable and that users can work without interruptions. You should monitor system performance, error logs, and user feedback to identify any issues. You should also have a support team available to address any issues that arise during the stabilization phase. This phase typically lasts for a few weeks, during which you should make any necessary adjustments to the system and provide additional training to users if needed.

Monitoring Performance and User Feedback

Monitoring performance and user feedback is essential during the stabilization phase. You should use monitoring tools to track system performance metrics, such as response times, error rates, and resource usage. You should also collect feedback from users to identify any issues that they are experiencing. This feedback can help you identify areas where the system needs improvement and provide insights into user adoption. By monitoring performance and user feedback, you can ensure that the system is stable and that users are satisfied with the upgrade.

Written by
SysGenPro Editorial

SysGenPro Editorial

Platform & solutions team

Practical guidance on ERP, AI automation, cloud deployment and enterprise transformation from the SysGenPro team.

Share this article

Frequently asked questions

Common questions on this topic. Talk to our team for anything specific to your business.

01Can I upgrade Odoo without changing the database schema?

No, Odoo upgrades typically involve changes to the database schema to support new features and improvements. You must plan for these changes and ensure that your custom code and data are compatible with the new schema.

02What happens to custom fields during an Odoo upgrade?

Custom fields are generally preserved during an upgrade, but they may need to be updated if the underlying model or field type has changed. You should test your custom fields in a staging environment to ensure they work correctly after the upgrade.

03How do I test database changes before a production upgrade?

You should create a staging environment that mirrors your production environment and run the upgrade process there. This allows you to identify and fix any issues before applying the upgrade to production.

04Is it safe to upgrade Odoo directly from two versions ago?

It depends on the specific versions involved. Odoo may not support direct upgrades from older versions to the latest release. You should check the official Odoo documentation for the supported upgrade paths.

05What are the main risks of Odoo database migration?

The main risks include data loss, broken custom code, incompatible modules, and downtime. You can mitigate these risks by performing thorough testing, creating backups, and having a rollback plan in place.

06How long does an Odoo database upgrade typically take?

The duration of an Odoo database upgrade depends on the size of the database, the complexity of the custom code, and the resources available. It can range from a few hours to several days. You should plan for downtime and communicate the expected duration to stakeholders.

Continue learning
View all articles
Explore the platform

Where to go next

Browse the knowledge hub

See how SysGenPro fits your business

Discuss your workflows, modules and deployment options with our team.

Back to resources