Skip to content

Commit 8794cec

Browse files
authored
Merge pull request #162 from bbkane/patch-1
Update README.md with http.FileSystem docs
2 parents 0633851 + d0d7b93 commit 8794cec

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Import sql-migrate into your application:
138138
import "github.com/rubenv/sql-migrate"
139139
```
140140

141-
Set up a source of migrations, this can be from memory, from a set of files or from bindata (more on that later):
141+
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):
142142

143143
```go
144144
// Hardcoded strings in memory:
@@ -168,6 +168,11 @@ migrations := &migrate.AssetMigrationSource{
168168
AssetDir: AssetDir,
169169
Dir: "migrations",
170170
}
171+
172+
// OR: Read migrations from a `http.FileSystem`
173+
migrationSource := &migrate.HttpFileSystemMigrationSource{
174+
FileSystem: httpFS,
175+
}
171176
```
172177

173178
Then use the `Exec` function to upgrade your database:
@@ -301,6 +306,16 @@ Both `Asset` and `AssetDir` are functions provided by bindata.
301306

302307
Then proceed as usual.
303308

309+
## Embedding migrations with libraries that implement `http.FileSystem`
310+
311+
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).
312+
313+
```go
314+
migrationSource := &migrate.HttpFileSystemMigrationSource{
315+
FileSystem: httpFS,
316+
}
317+
```
318+
304319
## Extending
305320

306321
Adding a new migration source means implementing `MigrationSource`.

0 commit comments

Comments
 (0)