Fix migration to handle tables missing is_local and is_worktree columns

This commit is contained in:
Chris Scott committed 2025-11-28 10:36:58 -05:00
1 parent 83834e7ed7
commit dfde798845
1 file changed
+8 -4
+8 -4
View File
@@ -25,10 +25,14 @@ export function runMigrations(db: Database): void {
is_local BOOLEAN DEFAULT FALSE
)
`)
db.run(`
INSERT INTO repos_new (id, repo_url, local_path, branch, default_branch, clone_status, cloned_at, last_pulled, opencode_config_name, is_worktree, is_local)
SELECT id, repo_url, local_path, branch, default_branch, clone_status, cloned_at, last_pulled, opencode_config_name, is_worktree, is_local FROM repos
`)
const existingColumns = tableInfo.map((col: any) => col.name)
const columnsToCopy = ['id', 'repo_url', 'local_path', 'branch', 'default_branch', 'clone_status', 'cloned_at', 'last_pulled', 'opencode_config_name', 'is_worktree', 'is_local']
.filter(col => existingColumns.includes(col))
const columnsStr = columnsToCopy.join(', ')
db.run(`INSERT INTO repos_new (${columnsStr}) SELECT ${columnsStr} FROM repos`)
db.run('DROP TABLE repos')
db.run('ALTER TABLE repos_new RENAME TO repos')
db.run('COMMIT')