Documentation
¶
Overview ¶
Package db handles database operations including schema management and migrations.
Index ¶
- Constants
- func Close(db *sql.DB) error
- func CreateChunkEmbeddingsTableSQL(dimensions int) string
- func GetEmbeddingDimensions(db *sql.DB) (int, error)
- func GetMeta(db *sql.DB, key string) (string, error)
- func IsWALEnabled(db *sql.DB) (bool, error)
- func MigrateEmbeddingDimensions(db *sql.DB, newDimensions int) error
- func Open(path string, embeddingDimensions int) (*sql.DB, error)
- func RunMigrations(db *sql.DB, embeddingDimensions int) error
- func SetEmbeddingDimensions(db *sql.DB, dimensions int) error
- func SetMeta(db *sql.DB, key, value string) error
- func VecVersion(db *sql.DB) (string, error)
Constants ¶
const CreateChunksTable = `` /* 464-byte string literal not displayed */
const CreateIndexChunksRepoID = `CREATE INDEX IF NOT EXISTS idx_chunks_repo_id ON chunks(repo_id)`
const CreateIndexRepoEmbeddedHash = `CREATE INDEX IF NOT EXISTS idx_repos_embedded_hash ON repos(embedded_hash)`
const CreateIndexRepoPushedAtHash = `CREATE INDEX IF NOT EXISTS idx_repos_pushed_at_hash ON repos(pushed_at_hash)`
const CreateIndexReposFullName = `CREATE INDEX IF NOT EXISTS idx_repos_full_name ON repos(full_name)`
Index definitions
const CreateIndexReposGitHubID = `CREATE INDEX IF NOT EXISTS idx_repos_github_id ON repos(github_id)`
const CreateIndexReposIsStarred = `CREATE INDEX IF NOT EXISTS idx_repos_is_starred ON repos(is_starred)`
const CreateIndexReposLanguage = `CREATE INDEX IF NOT EXISTS idx_repos_language ON repos(language)`
const CreateMetaTable = `
CREATE TABLE IF NOT EXISTS repog_meta (
key TEXT PRIMARY KEY,
value TEXT NOT NULL
)`
CreateMetaTable creates the metadata table for storing configuration
const CreateReposTable = `` /* 781-byte string literal not displayed */
const CreateSyncStateTable = `` /* 317-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CreateChunkEmbeddingsTableSQL ¶ added in v0.2.0
CreateChunkEmbeddingsTableSQL generates the embeddings table with dynamic dimensions
func GetEmbeddingDimensions ¶ added in v0.2.0
GetEmbeddingDimensions retrieves stored embedding dimensions, returns 0 if not set
func IsWALEnabled ¶
IsWALEnabled checks if WAL mode is enabled for the database.
func MigrateEmbeddingDimensions ¶ added in v0.2.0
MigrateEmbeddingDimensions drops and recreates the embeddings table with new dimensions. This is required when changing embedding models with different vector sizes. All existing embeddings will be lost and repos will need to be re-embedded.
func Open ¶
Open opens (or creates) the SQLite database at the given path, applies all pragmas, loads the sqlite-vec extension, and runs schema migrations. The caller is responsible for calling Close(). embeddingDimensions specifies the vector size for embeddings (e.g., 768 for Gemini).
func RunMigrations ¶
RunMigrations runs all schema migrations with the specified embedding dimensions. Each statement is idempotent (IF NOT EXISTS) so running migrations multiple times is safe. If the embedding dimensions change from what's stored, a migration is required.
func SetEmbeddingDimensions ¶ added in v0.2.0
SetEmbeddingDimensions stores the embedding dimensions
Types ¶
This section is empty.