db

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package db handles database operations including schema management and migrations.

Index

Constants

View Source
const CreateChunksTable = `` /* 464-byte string literal not displayed */
View Source
const CreateIndexChunksRepoID = `CREATE INDEX IF NOT EXISTS idx_chunks_repo_id ON chunks(repo_id)`
View Source
const CreateIndexRepoEmbeddedHash = `CREATE INDEX IF NOT EXISTS idx_repos_embedded_hash ON repos(embedded_hash)`
View Source
const CreateIndexRepoPushedAtHash = `CREATE INDEX IF NOT EXISTS idx_repos_pushed_at_hash ON repos(pushed_at_hash)`
View Source
const CreateIndexReposFullName = `CREATE INDEX IF NOT EXISTS idx_repos_full_name ON repos(full_name)`

Index definitions

View Source
const CreateIndexReposGitHubID = `CREATE INDEX IF NOT EXISTS idx_repos_github_id ON repos(github_id)`
View Source
const CreateIndexReposIsStarred = `CREATE INDEX IF NOT EXISTS idx_repos_is_starred ON repos(is_starred)`
View Source
const CreateIndexReposLanguage = `CREATE INDEX IF NOT EXISTS idx_repos_language ON repos(language)`
View Source
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

View Source
const CreateReposTable = `` /* 781-byte string literal not displayed */
View Source
const CreateSyncStateTable = `` /* 317-byte string literal not displayed */

Variables

This section is empty.

Functions

func Close

func Close(db *sql.DB) error

Close closes the database connection.

func CreateChunkEmbeddingsTableSQL added in v0.2.0

func CreateChunkEmbeddingsTableSQL(dimensions int) string

CreateChunkEmbeddingsTableSQL generates the embeddings table with dynamic dimensions

func GetEmbeddingDimensions added in v0.2.0

func GetEmbeddingDimensions(db *sql.DB) (int, error)

GetEmbeddingDimensions retrieves stored embedding dimensions, returns 0 if not set

func GetMeta added in v0.2.0

func GetMeta(db *sql.DB, key string) (string, error)

GetMeta retrieves a metadata value from the repog_meta table

func IsWALEnabled

func IsWALEnabled(db *sql.DB) (bool, error)

IsWALEnabled checks if WAL mode is enabled for the database.

func MigrateEmbeddingDimensions added in v0.2.0

func MigrateEmbeddingDimensions(db *sql.DB, newDimensions int) error

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

func Open(path string, embeddingDimensions int) (*sql.DB, error)

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

func RunMigrations(db *sql.DB, embeddingDimensions int) error

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

func SetEmbeddingDimensions(db *sql.DB, dimensions int) error

SetEmbeddingDimensions stores the embedding dimensions

func SetMeta added in v0.2.0

func SetMeta(db *sql.DB, key, value string) error

SetMeta stores a metadata value in the repog_meta table

func VecVersion

func VecVersion(db *sql.DB) (string, error)

VecVersion returns the sqlite-vec version to verify it's loaded.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL