Need Database Migration Path from v196 to v197 (OD-2370)
fzkin opened 9 months ago

Need Database Migration Path from v196 to v197

Description

Attempting to upgrade OneDev installation, but encountering version mismatch issues. Need guidance on the correct database migration path.

Current Situation

  • Database version: 196
  • Trying to upgrade to: OneDev 11.8.6 (data version 197)

Error Messages

When using OneDev 11.8.6: Data version mismatch (app data version: 197, db data version: 196) image.png

When downgrading to OneDev 11.8.5: ERROR - Unable to upgrade specified installation as data version of application and database is not the same INFO - *** After solving the problem, please restart container with correct image *** image_2.png

Environment

  • Deployment Method: Docker Compose
  • Database: PostgreSQL

Question

  1. Is there a specific migration path or SQL script needed to upgrade the database from version 196 to 197?
  2. What is the correct procedure to handle this database version mismatch?
  3. Are there any precautions needed before performing the database upgrade?

Additional Context

  • Unable to start the service with either version due to the version mismatch
  • Need guidance on the correct upgrade path to resolve this data version conflict
  • Looking for either:
    • Direct database upgrade script/procedure
    • Alternative upgrade method
    • Specific version that matches database version 196 for temporary rollback

What I've Tried

  1. Attempted to use OneDev 11.8.6 (failed due to version 197 vs 196)
  2. Attempted to downgrade to 11.8.5 (failed with upgrade error)

Any guidance on the correct upgrade path would be greatly appreciated.

  • fzkin commented 9 months ago

    Additional Information About Database Type

    I noticed that this issue might be related to the database type difference. While the official OneDev project uses native PostgreSQL, my installation uses pgvector (PostgreSQL with vector extension).

    Specific Concerns:

    1. Could the database version mismatch be related to pgvector compatibility?
    2. Is it possible that the automatic database structure synchronization code:
      • Works with native PostgreSQL
      • Fails with pgvector due to extension-specific differences

    Questions:

    1. Are there any known issues when using OneDev with pgvector instead of native PostgreSQL?
    2. Should we handle the database migration differently when using pgvector?
    3. Is there a recommended approach for version upgrades when using PostgreSQL with extensions?

    This might be important for other users who are using PostgreSQL with extensions rather than the standard PostgreSQL installation.

  • Robin Shen commented 9 months ago

    Data version 196 is corresponding to app version 11.8.4. Please use this version instead. If it starts fine, then change to use 11.8.6 for auto-migration.

  • fzkin commented 9 months ago

    Thank you for your suggestion. However, I'm encountering a different issue when following your advice:

    When trying to use version 11.8.4 (corresponding to data version 196), I get this error: ERROR - OneDev program is too old, please use a newer version

    So it seems I'm in a catch-22 situation:

    • 11.8.6 says the database version (196) is too old
    • 11.8.4 says the program is too old image_3.png

    This suggests there might be some intermediate state or version that I need to use. Could you please advise:

    1. Is there a specific version between 11.8.4 and 11.8.6 that I should try?
    2. Or is there another approach to resolve this version conflict?

    Additional context: As mentioned in my previous comment, I'm using pgvector (PostgreSQL with vector extension) rather than native PostgreSQL, which might be relevant to this situation.

  • fzkin commented 9 months ago

    I found some interesting details that might help understand the situation:

    1. Local File System Status:
    • All plugin JAR files in the lib directory are version 11.8.6 (authenticator-ldap, buildspec-bazel, buildspec-cmake, etc.)
    1. Database Status:
    • The o_modelversion table's o_versioncolumn value is 196
    • While all application files are at 11.8.6

    This seems to suggest:

    1. The file system has been updated to 11.8.6
    2. But the database schema is still at version 196
    3. The automatic migration didn't occur or failed

    Questions:

    1. Is it possible to manually upgrade the database schema from 196 to 197?
    2. If manual migration isn't possible, do I need to:
      • Start a fresh installation
      • Manually migrate projects and database information to the new instance?

    Looking for confirmation if my understanding is correct and what would be the safest path forward.

  • Robin Shen commented 9 months ago

    Assume OneDev volume is mounted from /data/onedev into /opt/onedev. Delete all files and directories under /data/onedev EXCEPT for below directories:

    1. /data/onedev/conf
    2. /data/onedev/site

    Then start the container using 11.8.4. After OneDev starts successfully, switch to 11.8.6.

  • fzkin commented 9 months ago

    Thank you for the migration solution!

    I actually solved it differently, but I appreciate your suggested approach which seems like a more standard solution that could help others:

    1. Keep only /conf and /site directories
    2. Start with 11.8.4
    3. Then upgrade to 11.8.6

    For reference, my solution was:

    • Generated an empty v197 database schema
    • Migrated compatible data from v196 to v197
    • It worked, but your solution seems more robust and official

    Thanks again for the help. This thread might be useful for others facing similar version mismatch issues, especially the official solution you provided which preserves critical data in /conf and /site directories.

  • Robin Shen commented 9 months ago

    Thanks for the summary. This issue normally happens when OneDev is configured to connect to a database used by some other OneDev version. As long as not changing database, this issue should never happen across upgrades. If you do want to migrate data from existing data, make sure to use database backup and restore.

  • Robin Shen changed state to 'Closed' 9 months ago
    Previous Value Current Value
    Open
    Closed
issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2370
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover