This library is heavily inspired by golang-migrate.
It currently lacks support for many database drivers and the CLI feature, this is still WIP.
But it is completely restructured to minimize the dependency footprint.
fsys := os.DirFS("/app/data") // Migration File Source Root (/app/data/migration-files)
source, err := NewFsSource(fsys, "migration-files")
if err != nil {
t.Fatalf("unable to setup source: %v", err)
}
defer source.Close()
driver, err := test.NewMockDriver() // Database Driver (for example mongodb.NewDriver() or mysql.NewDriver())
if err != nil {
t.Fatalf("unable to setup driver: %v", err)
}
defer driver.Close()
migrator, err := NewMigrator(source, driver, WithVerboseLogging(true)) // The migrator instance
if err != nil {
t.Fatalf("unable to setup migrator: %v", err)
}
err = migrator.Migrate(3) // Migrate to schema version 3
if err != nil {
t.Fatalf("migration error: %v", err)
}