Skip to content
Odoo Migration

Technical Deep Dive: Database Schema Changes in Odoo Version Upgrades

A technical guide for IT leaders on managing database schema changes during Odoo version upgrades, covering migration scripts, data integrity, custom module compatibility, and risk mitigation strategies.

9 min readSysGenPro Editorial
Technical Deep Dive: Database Schema Changes in Odoo Version Upgrades

Understanding Database Schema Changes in Odoo Upgrades

Upgrading Odoo involves more than updating application code; it requires managing significant changes to the underlying PostgreSQL database schema. The recommended approach is to treat the database migration as a distinct, high-risk phase that requires rigorous testing in a staging environment that mirrors production. This process matters because schema changes can alter data structures, field types, and relationships, potentially leading to data loss or application failures if not handled correctly. The main risks to control include incompatible custom modules, deprecated API calls, data type mismatches, and performance degradation due to changed indexing strategies. By understanding the technical mechanics of these changes, IT leaders can mitigate downtime and ensure operational continuity.

Assessing Source and Target Version Compatibility

Before initiating any migration, a detailed assessment of the source and target Odoo versions is essential. Odoo releases are not always backward compatible, and major version jumps often introduce breaking changes to the Object-Relational Mapping (ORM) layer. You must verify the specific PostgreSQL version requirements for the target Odoo release, as Odoo relies heavily on PostgreSQL features that may have changed between versions. For example, moving from an older Odoo version to a newer one might require upgrading PostgreSQL from version 10 to 14 or higher. Compatibility and support must be verified against the vendor's official documentation for the exact source and target versions. Do not assume that a direct upgrade path exists without checking the release notes for deprecated features or removed modules.

Identifying Deprecated Features

A critical part of the assessment is identifying deprecated features in the source version that have been removed in the target version. This includes specific ORM methods, view types, and security rule structures. Custom modules that rely on these deprecated features will fail during the upgrade process. Conduct a code audit to identify all custom modules and third-party add-ons that interact with the database schema. Create a compatibility matrix that lists each module, its current version, and its compatibility status with the target Odoo version. This matrix serves as the foundation for the remediation plan.

Analyzing Custom Module Dependencies

Custom modules are the primary source of risk in Odoo upgrades. These modules often contain direct SQL queries, custom ORM overrides, and view inheritances that are tightly coupled to the specific schema of the source version. When the schema changes, these customizations can break silently or cause critical errors. You must analyze the dependencies of each custom module to understand which database tables and fields it accesses. Look for hardcoded table names, direct SQL statements, and references to fields that may have been renamed or removed in the target version. Refactoring these modules to use the new ORM APIs and schema structures is often necessary before the upgrade can proceed.

Refactoring Custom Code

Refactoring custom code involves updating Python files, XML views, and SQL scripts to align with the target version's standards. This includes replacing deprecated ORM methods with their modern equivalents, updating view definitions to match new UI standards, and adjusting security rules to reflect any changes in access control logic. Automated testing should be used to validate these changes. Unit tests for custom models and integration tests for business processes should be run in a development environment to catch errors early. This proactive approach reduces the likelihood of failures during the production cutover.

Preparing the Staging Environment

A representative staging environment is crucial for validating database schema changes. This environment should be a clone of the production database, including all custom modules, data, and configurations. The size of the staging database should be comparable to production to accurately test performance and migration times. Ensure that the staging environment uses the same PostgreSQL version as the target production environment. This allows you to identify any performance issues related to database locking, query optimization, or index creation. Running the upgrade process in staging provides a safe space to observe how the schema changes affect data integrity and application behavior.

Simulating Production Conditions

To ensure the staging test is valid, simulate production conditions as closely as possible. This includes using the same hardware specifications, network latency, and data volumes. Run the upgrade process multiple times to measure the time required for each step. Identify any bottlenecks, such as long-running queries or table locks that could cause downtime in production. Document the results of these tests, including any errors encountered and the time taken to resolve them. This data will be used to create a realistic cutover plan and to set expectations for the downtime window.

Executing the Database Migration

The actual database migration involves running the Odoo upgrade scripts, which modify the PostgreSQL schema to match the target version. This process includes creating new tables, altering existing tables, adding or removing columns, and updating indexes. It is critical to take a full backup of the production database immediately before starting the migration. This backup serves as the rollback point if the upgrade fails. The migration should be performed during a scheduled maintenance window to minimize business impact. Monitor the migration process closely, watching for errors in the logs and any unexpected delays.

Monitoring Migration Progress

During the migration, monitor the progress of the schema changes in real-time. Use database monitoring tools to track the status of transactions, locks, and query execution times. If the migration stalls or encounters an error, assess the situation immediately. Determine if the error is critical or if it can be resolved without rolling back. If the error is critical, initiate the rollback procedure using the pre-upgrade backup. Document all steps taken during the migration, including any manual interventions, to create an audit trail for future reference.

Validating Data Integrity

After the migration is complete, validating data integrity is the most important step. This involves comparing the data in the new database with the data in the pre-upgrade backup. Use automated scripts to check for missing records, altered values, and broken relationships. Focus on critical business data, such as financial transactions, customer records, and inventory levels. Verify that all custom fields and relationships are intact and that the data types have been converted correctly. Any discrepancies must be investigated and resolved before the system is released to users.

Running Reconciliation Checks

Reconciliation checks involve comparing key metrics between the old and new systems. For example, compare the total value of accounts receivable, the count of active customers, and the sum of inventory quantities. These checks provide a high-level view of data integrity and can quickly identify major issues. If discrepancies are found, drill down into specific records to identify the root cause. This may involve checking for data type conversion errors, missing foreign keys, or failed migration scripts. Resolve all discrepancies before proceeding to user acceptance testing.

Testing Application Functionality

Once data integrity is confirmed, test the application functionality to ensure that all business processes work correctly. This includes testing core modules, such as Sales, Purchase, Inventory, and Accounting, as well as any custom modules. Perform end-to-end tests that simulate real-world business scenarios. Verify that reports generate correctly, that workflows function as expected, and that user permissions are enforced. Pay special attention to any areas where the schema changed significantly, as these are likely to have the most impact on application behavior. Document any issues found and prioritize them for resolution.

User Acceptance Testing

User Acceptance Testing (UAT) involves key users from the business validating that the system meets their requirements. Provide UAT participants with a test plan that covers their specific workflows. Collect feedback on any issues or concerns they encounter. This step is crucial for ensuring that the upgrade does not disrupt business operations. Address any critical issues identified during UAT before the production cutover. Non-critical issues can be addressed in a post-go-live support phase, but they should be documented and tracked for resolution.

Planning the Production Cutover

The production cutover is the final step in the upgrade process. It should be planned meticulously to minimize downtime and risk. Define a clear cutover plan that includes the start and end times, the roles and responsibilities of each team member, and the communication plan for stakeholders. Establish go/no-go criteria that must be met before the cutover can proceed. These criteria should include successful completion of all tests, resolution of critical issues, and confirmation of a valid backup. Have a rollback plan ready in case the cutover fails. The rollback plan should specify the steps to restore the pre-upgrade backup and the time required to complete the rollback.

Executing the Cutover

During the cutover, follow the plan strictly. Start by taking a final backup of the production database. Then, run the upgrade scripts and monitor the process closely. Once the upgrade is complete, perform a quick validation of data integrity and application functionality. If all checks pass, declare the cutover successful and notify stakeholders. If any checks fail, initiate the rollback procedure. After the cutover, provide immediate support to users to address any issues that arise. Monitor the system closely for the first few days to identify any performance or stability issues.

Post-Upgrade Stabilization

The upgrade is not complete until the system is stable in production. The post-upgrade stabilization phase involves monitoring the system for performance issues, resolving any remaining bugs, and providing support to users. Track key performance indicators, such as response times, error rates, and user satisfaction. Address any issues that arise promptly to maintain user confidence. Document all changes made during the stabilization phase and update the technical documentation accordingly. This phase is critical for ensuring that the upgrade delivers the expected benefits and that the system remains reliable in the long term.

Long-Term Maintenance

After the stabilization phase, transition the system to normal maintenance. This includes regular backups, performance monitoring, and security updates. Establish a process for managing future upgrades and changes to the system. Ensure that all custom modules are kept up-to-date with the latest Odoo version. Regularly review the system for any technical debt or areas for improvement. By maintaining a proactive approach to system management, you can ensure that the Odoo installation remains stable, secure, and aligned with business needs.

PhaseKey ActivitiesResponsible RoleRisk Level
AssessmentVersion compatibility check, custom module auditERP ConsultantMedium
PreparationStaging environment setup, code refactoringIT DirectorHigh
MigrationDatabase backup, schema upgrade, data validationDBACritical
TestingUAT, performance testing, reconciliationQA LeadMedium
CutoverProduction upgrade, rollback plan executionProject ManagerCritical
  • Always take a full backup before starting the migration.
  • Test the upgrade in a staging environment that mirrors production.
  • Refactor custom modules to ensure compatibility with the target version.
  • Validate data integrity using automated reconciliation scripts.
  • Have a documented rollback plan ready before the cutover.
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.

01What are the most common database errors during Odoo upgrades?

Common errors include foreign key constraint violations, data type mismatches, and missing indexes. These often occur when custom modules rely on deprecated schema structures or when data is not properly transformed during the migration.

02How do I test database schema changes before production?

Use a staging environment that is a clone of the production database. Run the upgrade scripts in this environment and validate data integrity and application functionality before proceeding to production.

03Can I roll back an Odoo database upgrade if it fails?

Yes, if you have a valid pre-upgrade backup. The rollback process involves restoring the backup and reverting any application code changes. It is critical to test the rollback procedure in staging before the production cutover.

04Do custom modules always break during Odoo version upgrades?

Not always, but they are at high risk. Custom modules that use deprecated APIs or direct SQL queries are more likely to break. Refactoring these modules to use modern ORM APIs can reduce the risk.

05What is the role of PostgreSQL in Odoo migrations?

PostgreSQL is the underlying database for Odoo. Schema changes in Odoo are implemented as PostgreSQL DDL statements. Ensuring PostgreSQL version compatibility and monitoring database performance are critical for a successful migration.

06How long does a typical Odoo database migration take?

The time required depends on the size of the database and the complexity of the schema changes. Small databases may take minutes, while large databases with many custom modules can take hours. Always test the migration time in staging to plan the downtime window.

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