23 lines
404 B
Go
23 lines
404 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"embed"
|
|
"fmt"
|
|
|
|
"github.com/pressly/goose/v3"
|
|
)
|
|
|
|
func Migrate(db *sql.DB, migrations embed.FS) error {
|
|
goose.SetBaseFS(migrations)
|
|
|
|
if err := goose.SetDialect("sqlite3"); err != nil {
|
|
return fmt.Errorf("setting goose dialect: %w", err)
|
|
}
|
|
|
|
if err := goose.Up(db, "migrations"); err != nil {
|
|
return fmt.Errorf("running migrations: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|