migrate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package migrate owns the schema of the rag module: the knowledge-base tables (kb_documents, kb_chunks, kb_fts, kb_links) and the session events tables, as goose SQL migrations.

There are two ways to apply them:

  • A program that only uses the rag module calls Up, which records the applied versions in its own table, rag_goose_version, so it never collides with another goose history in the same database.
  • Pando, whose existing databases already recorded these exact versions in its own goose_db_version table, does not call Up. It merges FS into its migration directory with Merge and keeps running a single goose history. The file names and versions here are the ones Pando has always shipped, so an existing database sees nothing new.

New migrations for the rag schema are added here, with versions later than every existing one, and reach both kinds of consumer.

Index

Constants

View Source
const Dir = "sql"

Dir is the directory inside FS that holds the SQL migrations.

View Source
const TableName = "rag_goose_version"

TableName is the goose version table Up uses.

Variables

FS holds the rag schema migrations under Dir.

Functions

func Merge

func Merge(base fs.FS, dir string) (fs.FS, error)

Merge returns a filesystem that is base with the rag migrations added to its directory dir, so a single goose run (goose.SetBaseFS(merged); goose.Up(db, dir)) applies both sets in version order under one history.

It fails when a rag migration has the same file name or the same goose version as a file already in base/dir: two migrations with one version would make goose skip one of them silently.

func Pending

func Pending(ctx context.Context, db *sql.DB) (int, error)

Pending reports how many rag migrations Up would still apply to db.

func Up

func Up(ctx context.Context, db *sql.DB) error

Up applies every pending rag migration to db, recording them in TableName. db must be a SQLite database with FTS5 available.

Types

This section is empty.

Jump to

Keyboard shortcuts

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