Uh oh!
There was an error while loading. Please reload this page.
fix: migrate sessions from global to git project after init - #17150
fix: migrate sessions from global to git project after init#17150Wangmerlyn wants to merge 1 commit into
Conversation
Fixesanomalyco#16812 The migrateFromGlobal function was being called before the project row was inserted into the database, causing a foreign key constraint violation. Additionally, it only ran when creating a new project row, not when an existing project transitioned from global to git-based ID. Changes: - Move migrateFromGlobal call to after project row insertion - Ensure migration runs even when project row already exists - Add test to verify session migration after git init Closesanomalyco#16812
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
The following comment was made by an LLM, it may be inaccurate: Found a potential related PR: PR #16814: fix(opencode): sessions lost after git init in existing project This PR appears to address the same issue as PR #17150 - sessions being lost or not properly migrated when git is initialized in an existing project. Both PRs deal with the |
Wangmerlyn
commented
Mar 12, 2026
Closed as this is the same as PR #16814 |
Fixes#16812
Problem
Sessions created before a git repository has commits are stored under
project_id = "global". When a commit is made and opencode resolves a real project ID (the root commit SHA), the sessions were not being migrated properly.Root Causes
migrateFromGlobal()was called before the target project row was inserted into theprojecttable, causing the UPDATE to be rejected due to the foreign key constraint onsession.project_id.if (!row)branch — i.e., only when a new project row was created. Sessions accumulated under "global" after the real project row already existed were never migrated.Solution
migrateFromGlobal()call to after the project row is inserted/updatedfromDirectoryis called with a non-global project ID, not just when creating a new project rowVerification
migrates sessions from global to git project after git init