Release 2026.08.02-1

SQLite replaces Postgres, and two fixes from using the thing.

- The database is a file under ./storage instead of a second container. Ten
  members never needed a database server, and the driver is pure Go, so the
  build stays CGO_ENABLED=0 and the dependency count is unchanged. One bind
  mount is now the whole backup: no pgdata, no healthcheck-gated depends_on,
  no startup retry loop. Timestamps are UTC text, idle_ttl is seconds, the
  divisive/unified boards carry their own stddev, and foreign keys are on by
  pragma. Tests get a database file each and run without any setup
- Invites are copied, not clicked. An invite is something to send, and the
  anchor opened the join form in the admin's own browser
- Feedback asks for more than faults: the footer reads "Ongelmia? Ideoita?
  Palautetta?" and the page behind it invites ideas rather than only bugs
- Kuuntele YouTubessa opens in a new tab, so a half-typed review survives it
This commit is contained in:
Esa Kataja
2026-08-02 20:58:52 +03:00
parent 400b5d3833
commit 0f15ae0bfc
33 changed files with 480 additions and 396 deletions
+20 -19
View File
@@ -2,12 +2,11 @@ package main
import (
"context"
"database/sql"
"embed"
"fmt"
"log/slog"
"sort"
"github.com/jackc/pgx/v5/pgxpool"
)
//go:embed migrations/*.sql
@@ -15,17 +14,17 @@ var migrationFS embed.FS
// migrate applies every migrations/*.sql not yet recorded, in filename order, each in its own
// transaction. Applied names are the record — a file that changes after it ran is not re-applied.
func migrate(ctx context.Context, pool *pgxpool.Pool) error {
_, err := pool.Exec(ctx, `create table if not exists schema_migrations (
func migrate(ctx context.Context, db *sql.DB) error {
_, err := db.ExecContext(ctx, `create table if not exists schema_migrations (
name text primary key,
applied_at timestamptz not null default now()
applied_at timestamp not null default (datetime('now'))
)`)
if err != nil {
return fmt.Errorf("create schema_migrations: %w", err)
}
applied := map[string]bool{}
rows, err := pool.Query(ctx, `select name from schema_migrations`)
rows, err := db.QueryContext(ctx, `select name from schema_migrations`)
if err != nil {
return fmt.Errorf("read schema_migrations: %w", err)
}
@@ -60,19 +59,19 @@ func migrate(ctx context.Context, pool *pgxpool.Pool) error {
if err != nil {
return err
}
tx, err := pool.Begin(ctx)
tx, err := db.BeginTx(ctx, nil)
if err != nil {
return err
}
if _, err := tx.Exec(ctx, string(sql)); err != nil {
tx.Rollback(ctx)
if _, err := tx.ExecContext(ctx, string(sql)); err != nil {
tx.Rollback()
return fmt.Errorf("migration %s: %w", name, err)
}
if _, err := tx.Exec(ctx, `insert into schema_migrations (name) values ($1)`, name); err != nil {
tx.Rollback(ctx)
if _, err := tx.ExecContext(ctx, `insert into schema_migrations (name) values ($1)`, name); err != nil {
tx.Rollback()
return err
}
if err := tx.Commit(ctx); err != nil {
if err := tx.Commit(); err != nil {
return fmt.Errorf("migration %s: %w", name, err)
}
slog.Info("migration applied", "ctx", "startup", "name", name)
@@ -82,29 +81,31 @@ func migrate(ctx context.Context, pool *pgxpool.Pool) error {
// sweep runs the startup cleanup from docs/spec.md §4.6. An in-process conversion goroutine dies
// with the process, so without this those rows say "converting" forever.
func sweep(ctx context.Context, pool *pgxpool.Pool) error {
tag, err := pool.Exec(ctx, `update submissions
func sweep(ctx context.Context, db *sql.DB) error {
res, err := db.ExecContext(ctx, `update submissions
set status = 'failed', status_msg = 'interrupted by restart'
where status in ('queued', 'downloading', 'converting')`)
if err != nil {
return err
}
if n := tag.RowsAffected(); n > 0 {
if n := affected(res); n > 0 {
slog.Warn("submissions interrupted by restart", "ctx", "startup", "count", n)
}
// ponytail: temp files of swept submissions are unlinked with the row in step 3, once the
// pipeline exists and there is something to unlink.
if _, err := pool.Exec(ctx,
`delete from submissions where created_at < now() - interval '7 days'`); err != nil {
if _, err := db.ExecContext(ctx,
`delete from submissions where created_at < datetime('now', '-7 days')`); err != nil {
return err
}
if _, err := pool.Exec(ctx, `delete from sessions where expires_at < now()`); err != nil {
if _, err := db.ExecContext(ctx,
`delete from sessions where expires_at < datetime('now')`); err != nil {
return err
}
var failed int
err = pool.QueryRow(ctx, `select count(*) from submissions where status = 'failed'`).Scan(&failed)
err = db.QueryRowContext(ctx,
`select count(*) from submissions where status = 'failed'`).Scan(&failed)
if err != nil {
return err
}