Files
homebox/backend/internal/data/migrations/migrations.go
Matt Kilgore 1ac86d9c04 Real Migrations System (#645)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-05-01 15:03:08 -04:00

32 lines
875 B
Go

// Package migrations
package migrations
import (
"embed"
"github.com/rs/zerolog/log"
)
//go:embed all:postgres
var postgresFiles embed.FS
//go:embed all:sqlite3
var sqliteFiles embed.FS
// Migrations returns the embedded file system containing the SQL migration files
// for the specified SQL dialect. It uses the "embed" package to include the
// migration files in the binary at build time. The function takes a string
// parameter "dialect" which specifies the SQL dialect to use. It returns an
// embedded file system containing the migration files for the specified dialect.
func Migrations(dialect string) embed.FS {
switch dialect {
case "postgres":
return postgresFiles
case "sqlite3":
return sqliteFiles
default:
log.Fatal().Str("dialect", dialect).Msg("unknown sql dialect")
}
// This should never get hit, but just in case
return sqliteFiles
}