diff --git a/README.md b/README.md index 36488556..c87ee09a 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Import sql-migrate into your application: import "github.com/rubenv/sql-migrate" ``` -Set up a source of migrations, this can be from memory, from a set of files or from bindata (more on that later): +Set up a source of migrations, this can be from memory, from a set of files, from bindata (more on that later), or from any library that implements [`http.FileSystem`](https://godoc.org/net/http#FileSystem): ```go // Hardcoded strings in memory: @@ -168,6 +168,11 @@ migrations := &migrate.AssetMigrationSource{ AssetDir: AssetDir, Dir: "migrations", } + +// OR: Read migrations from a `http.FileSystem` +migrationSource := &migrate.HttpFileSystemMigrationSource{ + FileSystem: httpFS, +} ``` Then use the `Exec` function to upgrade your database: @@ -301,6 +306,16 @@ Both `Asset` and `AssetDir` are functions provided by bindata. Then proceed as usual. +## Embedding migrations with libraries that implement `http.FileSystem` + +You can also embed migrations with any library that implements `http.FileSystem`, like [`vfsgen`](https://github.com/shurcooL/vfsgen), [`parcello`](https://github.com/phogolabs/parcello), or [`go-resources`](https://github.com/omeid/go-resources). + +```go +migrationSource := &migrate.HttpFileSystemMigrationSource{ + FileSystem: httpFS, +} +``` + ## Extending Adding a new migration source means implementing `MigrationSource`.