mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fix migration to handle tables missing is_local and is_worktree columns
This commit is contained in:
1 parent
83834e7ed7
commit
dfde798845
1 file changed
+8
-4
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user