The Go API on PostgreSQL ingests desktop, browser, presence, manual and Health Auto Export events and serves activities and daily goal summaries. The Hyprland agent records window focus, idle and lock intervals. The CI workflow publishes adam-french.co.uk/adamf/activity-tracker to the Gitea registry and rolls the web_server stack onto it. The image probes itself through a new `tracker healthcheck` command, because distroless has no wget. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31 lines
658 B
Go
31 lines
658 B
Go
// Package migrations embeds the SQL schema migrations and applies them with goose.
|
|
package migrations
|
|
|
|
import (
|
|
"context"
|
|
"embed"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
"github.com/jackc/pgx/v5/stdlib"
|
|
"github.com/pressly/goose/v3"
|
|
)
|
|
|
|
//go:embed *.sql
|
|
var files embed.FS
|
|
|
|
// Up applies all pending migrations.
|
|
func Up(ctx context.Context, pool *pgxpool.Pool) error {
|
|
db := stdlib.OpenDBFromPool(pool)
|
|
defer db.Close()
|
|
|
|
p, err := goose.NewProvider(goose.DialectPostgres, db, files)
|
|
if err != nil {
|
|
return fmt.Errorf("goose provider: %w", err)
|
|
}
|
|
if _, err := p.Up(ctx); err != nil {
|
|
return fmt.Errorf("migrate up: %w", err)
|
|
}
|
|
return nil
|
|
}
|