From a57a1ff5f5176b1352d4886b2c1f4063b3732873 Mon Sep 17 00:00:00 2001 From: ylfz Date: Sun, 5 Apr 2026 22:41:21 +0700 Subject: [PATCH] fix: rename 'commit' column to 'commit_hash' in federation schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'commit' is a SQLite reserved keyword (COMMIT TRANSACTION). The modernc.org/sqlite driver enforces this strictly, causing 'ckb federation create' to fail with: SQL logic error: near "commit": syntax error (1) This blocks all federation functionality on affected platforms. Fix: rename the column to 'commit_hash' in: - remote_repos table schema (line 252) - remote_repos migration (line 382) - UpsertRemoteRepo INSERT (line 670) - GetRemoteRepos SELECT (line 681) - GetAllRemoteRepos SELECT (line 712) The Go struct field 'Commit' is unchanged — Scan() uses positional binding, not column name mapping. Fixes #201 --- internal/federation/index.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/federation/index.go b/internal/federation/index.go index 647d7d6b..b4c2f211 100644 --- a/internal/federation/index.go +++ b/internal/federation/index.go @@ -249,7 +249,7 @@ CREATE TABLE IF NOT EXISTS remote_repos ( repo_id TEXT NOT NULL, name TEXT, description TEXT, - commit TEXT, + commit_hash TEXT, languages TEXT, -- JSON array symbol_count INTEGER, file_count INTEGER, @@ -379,7 +379,7 @@ func (idx *Index) migrate(fromVersion int) error { repo_id TEXT NOT NULL, name TEXT, description TEXT, - commit TEXT, + commit_hash TEXT, languages TEXT, symbol_count INTEGER, file_count INTEGER, @@ -667,7 +667,7 @@ type CachedRemoteRepo struct { func (idx *Index) UpsertRemoteRepo(repo *CachedRemoteRepo) error { _, err := idx.db.Exec(` INSERT OR REPLACE INTO remote_repos - (server_name, repo_id, name, description, commit, languages, symbol_count, file_count, sync_seq, index_version, cached_at) + (server_name, repo_id, name, description, commit_hash, languages, symbol_count, file_count, sync_seq, index_version, cached_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `, repo.ServerName, repo.RepoID, repo.Name, repo.Description, repo.Commit, repo.Languages, repo.SymbolCount, repo.FileCount, repo.SyncSeq, repo.IndexVersion, @@ -678,7 +678,7 @@ func (idx *Index) UpsertRemoteRepo(repo *CachedRemoteRepo) error { // GetRemoteRepos returns all cached repos for a server func (idx *Index) GetRemoteRepos(serverName string) ([]*CachedRemoteRepo, error) { rows, err := idx.db.Query(` - SELECT server_name, repo_id, name, description, commit, languages, + SELECT server_name, repo_id, name, description, commit_hash, languages, symbol_count, file_count, sync_seq, index_version, cached_at FROM remote_repos WHERE server_name = ? ORDER BY repo_id `, serverName) @@ -709,7 +709,7 @@ func (idx *Index) GetRemoteRepos(serverName string) ([]*CachedRemoteRepo, error) // GetAllRemoteRepos returns all cached repos from all servers func (idx *Index) GetAllRemoteRepos() ([]*CachedRemoteRepo, error) { rows, err := idx.db.Query(` - SELECT server_name, repo_id, name, description, commit, languages, + SELECT server_name, repo_id, name, description, commit_hash, languages, symbol_count, file_count, sync_seq, index_version, cached_at FROM remote_repos ORDER BY server_name, repo_id `)