Files
zampler/internal/database/db.go
T
claudeandClaude Sonnet 5 800404203a
PR Checks / checks (pull_request) Successful in 1m43s
Build / build-and-push (push) Successful in 1m8s
replace archived code.aneur.in/go/* dependencies
Everything under code.aneur.in/go/* except validate was archived. Swap
each for its replacement; validate stays.

- rest -> internal/rest: the JSON response/error helpers zampler actually
  uses (~110 lines), same {"message","data"} wire shape and status codes.
- sqan -> internal/scan: a filepath.WalkDir walk. zampler only filtered
  by extension; sqan's path semantics (absolute root, rooted RelativePath,
  "/" RelativeDir for root-level files) are kept.
- sqimple + sqaffold query building -> github.com/doug-martin/goqu/v9,
  which also does the row scanning that record + sqaffold provided. A
  fileRow struct with db tags maps to types.File (millis <-> time.Time).
- sqaffold.Migrate + version.Migration -> a ~40-line migrator in
  internal/database/migration.go tracking applied names in a
  schema_migrations table. goose was disproportionate for one migration.
- version -> gone (only its Migration helper was used).

Net dependency change: -6 code.aneur.in/go modules, +1 (goqu).

go build / go vet / go test ./... green; manual run verified migration,
scan+insert, list/get/search/sort/paging, 404 and 400 shapes, and
rescan idempotency (on conflict replace).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 17:00:45 +01:00

28 lines
428 B
Go

package database
import (
"context"
"database/sql"
"github.com/doug-martin/goqu/v9"
_ "github.com/doug-martin/goqu/v9/dialect/sqlite3"
"github.com/rs/zerolog"
)
type DB struct {
ctx context.Context
log zerolog.Logger
conn *sql.DB
g *goqu.Database
}
func New(ctx context.Context, log zerolog.Logger, conn *sql.DB) *DB {
return &DB{
ctx: ctx,
log: log,
conn: conn,
g: goqu.New("sqlite3", conn),
}
}