This migration library was in dire need of an update, to make it easier to maintain and use.
Changelog
- Functionality has been encapsulated, so that migrations can be managed for multiple databases without trampling each other's configuration.
- Migrations now need to be registered in a
Registry
object.- This does mean that the pattern of globally registering migrations in
init()
methods no longer work. The workaround is to define aRegistry
(by value, not pointer) in the package where migrations are generated. The zero-value of the registry is ready for use, so it doesn't need special initialisation. - The
Registry
should be thread-safe.
- This does mean that the pattern of globally registering migrations in
- Functionality is now accessed by running methods on a
Migrator
. This should be easier to use than emulating command-line arguments without proper type-checking. - Case conversion now allocates fewer strings.
- Configuration is achieved by the options pattern. Any of the
With*()
functions can be called and passed to theMigrator
's constructor as additional arguments. - The package now defines a number of errors, which can be easily checked with
errors.Is()
fromgithub.com/pkg/errors
.