Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-11465. Introducing Schema Versioning for Recon Derby table to Handle Fresh Installs and Upgrades. #7213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ArafatKhan2198
Copy link
Contributor

What changes were proposed in this pull request?

In Recon, as new features and enhancements are introduced, changes to the database schema are required. Versioning ensures that Recon’s schema is upgraded smoothly across different installations and updates. It helps track which version of the schema is currently applied, preventing inconsistencies between the code and the database.

Summary of Changes:

  • Introduced Schema Versioning System:

    • Implemented a mechanism to track the schema version in a dedicated ReconSchemaVersionTable.
    • All schema version upgrades for the different tables are coordinated to ensure consistency across the system.
  • Added upgradeSchema Method to Schema Definitions:

    • Each table's schema definition now includes an upgradeSchema method to handle version-specific migrations. This method is responsible for running any necessary DDL changes when upgrading to a new schema version.
  • Modified ReconSchemaManager:

    • The createAndUpgradeReconSchema method was updated to first initialize all tables, then loop through each table's upgradeSchema method to apply migrations if needed.
    • This ensures that all tables are created or upgraded in sync with the version specified in the system.
  • New ReconSchemaVersionTableManager Class:

    • Added a new class responsible for fetching and updating the schema version from the ReconSchemaVersionTable.
    • This class manages reading the current schema version and updating it once all migrations have been successfully applied.
  • Centralized Version Tracking:

    • Defined the current schema version for the entire system in a central configuration file (ReconConstants).
    • This version acts as the reference point for both initial schema creation and migrations. All tables will be migrated in line with this version.
  • These changes ensure that the database schema remains consistent with the application code as it evolves, allowing smooth upgrades and initialization across different environments.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11465

How was this patch tested?

Manually Tested

@errose28
Copy link
Contributor

Thanks for working on this @ArafatKhan2198. Can we use the existing concept of "layout features" for Recon the same as they are used on other components instead of introducing a new concept unique to Recon? Recon will need to support downgrades the same as other components, and once we start versioning things it will be easier to let the existing upgrade framework handle that.

@ArafatKhan2198 ArafatKhan2198 marked this pull request as ready for review September 18, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants