Documentation ¶
Overview ¶
Package iofs contains functions that allows to work with migration using io/fs package.
Index ¶
- func CollectMigrations(fsys fs.FS, dirpath string, current, target int64) (goose.Migrations, error)
- func Down(db *sql.DB, fsys fs.FS, dir string) error
- func DownTo(db *sql.DB, fsys fs.FS, dir string, version int64) error
- func Redo(db *sql.DB, fsys fs.FS, dir string) error
- func Reset(db *sql.DB, fsys fs.FS, dir string) error
- func Status(db *sql.DB, fsys fs.FS, dir string) error
- func Up(db *sql.DB, fsys fs.FS, dir string) error
- func UpByOne(db *sql.DB, fsys fs.FS, dir string) error
- func UpTo(db *sql.DB, fsys fs.FS, dir string, version int64) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectMigrations ¶
CollectMigrations returns all the valid looking migration scripts in the migrations folder and key them by version.
func Up ¶
Up applies all available migrations.
Example ¶
package main import ( "database/sql" "embed" "log" "github.com/vearutop/gooselite/iofs" ) //go:embed testdata var migrations embed.FS func main() { db, err := sql.Open("sqlite3", "sql.db") if err != nil { log.Fatalf("Failed to open test database: %v", err) } if err := iofs.Up(db, migrations, "testdata/migrations"); err != nil { log.Fatalf("Failed to run up migrations: %v", err) } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.