- pluggable per-domain Repository interfaces; PostgreSQL and SQLite impls - SQLite on modernc.org/sqlite (WAL, busy_timeout, foreign_keys, immediate tx) - separate migrations/sqlite and db.MigrateSQLite; store.NewPostgres/NewSQLite - cmd/reconcile compares object storage with the journal (report, then --delete) - storage.Backend.List and photos.Repository.AllStorageKeys - DB_BACKEND/SQLITE_PATH and STORAGE_BACKEND/FS_ROOT selectable; local defaults (sqlite ./galo.db, fs ./data) - Makefile reconcile/reconcile-delete; docs and .env.example updated
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
// Package store builds the per-domain metadata repositories for a chosen
|
|
// backend. Domains depend on their Repository interfaces; this factory is the
|
|
// single place that knows the concrete implementations.
|
|
package store
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
|
|
"shared-album/internal/albums"
|
|
"shared-album/internal/auth"
|
|
"shared-album/internal/members"
|
|
"shared-album/internal/notifications"
|
|
"shared-album/internal/photos"
|
|
"shared-album/internal/sharelinks"
|
|
"shared-album/internal/social"
|
|
)
|
|
|
|
// Repos bundles one repository per domain.
|
|
type Repos struct {
|
|
Auth auth.Repository
|
|
Albums albums.Repository
|
|
Members members.Repository
|
|
Photos photos.Repository
|
|
Social social.Repository
|
|
Notifications notifications.Repository
|
|
ShareLinks sharelinks.Repository
|
|
}
|
|
|
|
// NewPostgres builds the repositories backed by PostgreSQL.
|
|
func NewPostgres(pool *pgxpool.Pool) Repos {
|
|
return Repos{
|
|
Auth: auth.NewStore(pool),
|
|
Albums: albums.NewStore(pool),
|
|
Members: members.NewStore(pool),
|
|
Photos: photos.NewStore(pool),
|
|
Social: social.NewStore(pool),
|
|
Notifications: notifications.NewStore(pool),
|
|
ShareLinks: sharelinks.NewStore(pool),
|
|
}
|
|
}
|
|
|
|
// NewSQLite builds the repositories backed by SQLite.
|
|
func NewSQLite(db *sql.DB) Repos {
|
|
return Repos{
|
|
Auth: auth.NewSQLiteStore(db),
|
|
Albums: albums.NewSQLiteStore(db),
|
|
Members: members.NewSQLiteStore(db),
|
|
Photos: photos.NewSQLiteStore(db),
|
|
Social: social.NewSQLiteStore(db),
|
|
Notifications: notifications.NewSQLiteStore(db),
|
|
ShareLinks: sharelinks.NewSQLiteStore(db),
|
|
}
|
|
}
|