sonda/migrations/embed.go
tgiachi 3a739dc3ae feat: add sondad server with config, storage, auth and listening API
- feat(config): TOML config with env overrides, strict parsing and validation
- feat(storage): SQLite (modernc) and PostgreSQL (pgx) backends through bun,
  embedded per-driver SQL migrations with a transactional runner
- feat(schema): catalog tables (artists, albums, tracks, audio_files with
  per-root paths), users and listening events with idempotency keys
- feat(auth): Argon2id password hashing, HS256 JWT tokens, first-user-only
  registration and login
- feat(api): gin REST API under /api/v1 (health, register, login, listens)
  with a consistent error envelope, body limit and request logging
- feat(sondad): zap logger, graceful shutdown, composition root in main
- chore: example config, .gitignore for secrets, DB files, IDE and agent files
2026-11-11 12:06:15 +01:00

29 lines
679 B
Go

// Package migrations embeds the versioned SQL migrations, one folder per
// database driver. Both folders must describe the same schema.
//
// Files are named NNNN_description.sql and applied in lexical order.
package migrations
import (
"embed"
"fmt"
"io/fs"
)
//go:embed sqlite/*.sql
var sqliteFS embed.FS
//go:embed postgres/*.sql
var postgresFS embed.FS
// For returns the migrations for driver ("sqlite" or "postgres").
func For(driver string) (fs.FS, error) {
switch driver {
case "sqlite":
return fs.Sub(sqliteFS, "sqlite")
case "postgres":
return fs.Sub(postgresFS, "postgres")
default:
return nil, fmt.Errorf("unknown database driver %q", driver)
}
}