- rename Go module, binary, systemd unit, PG_DATABASE default, frontend package and docs from shared-album to galo - add theme-aware halo emblem and favicon (new ui-branding capability) - add make build-release (versioned, stripped, static binary) and run the binary from the repo root
38 lines
792 B
Go
38 lines
792 B
Go
package db
|
|
|
|
import (
|
|
"io/fs"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
assets "galo"
|
|
)
|
|
|
|
func TestMigrateSQLite(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "meta.db")
|
|
migFS, err := fs.Sub(assets.Migrations, "migrations/sqlite")
|
|
if err != nil {
|
|
t.Fatalf("migrations fs: %v", err)
|
|
}
|
|
if err := MigrateSQLite(path, migFS); err != nil {
|
|
t.Fatalf("migrate: %v", err)
|
|
}
|
|
if err := MigrateSQLite(path, migFS); err != nil {
|
|
t.Fatalf("migrate again: %v", err)
|
|
}
|
|
|
|
db, err := OpenSQLite(path)
|
|
if err != nil {
|
|
t.Fatalf("open: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
var n int
|
|
if err := db.QueryRow(`SELECT count(*) FROM sqlite_master WHERE type='table' AND name='objects'`).Scan(&n); err != nil {
|
|
t.Fatalf("query: %v", err)
|
|
}
|
|
if n != 1 {
|
|
t.Fatalf("objects table missing after migration")
|
|
}
|
|
}
|