File tree Expand file tree Collapse file tree 3 files changed +22
-64
lines changed Expand file tree Collapse file tree 3 files changed +22
-64
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,34 @@ import (
66 "path/filepath"
77
88 "github.com/golang-migrate/migrate/v4/source"
9+ "github.com/golang-migrate/migrate/v4/source/iofs"
910)
1011
1112func init () {
1213 source .Register ("file" , & File {})
1314}
1415
16+ type File struct {
17+ iofs.PartialDriver
18+ url string
19+ path string
20+ }
21+
22+ func (f * File ) Open (url string ) (source.Driver , error ) {
23+ p , err := parseURL (url )
24+ if err != nil {
25+ return nil , err
26+ }
27+ nf := & File {
28+ url : url ,
29+ path : p ,
30+ }
31+ if err := nf .Init (os .DirFS (p ), "." ); err != nil {
32+ return nil , err
33+ }
34+ return nf , nil
35+ }
36+
1537func parseURL (url string ) (string , error ) {
1638 u , err := nurl .Parse (url )
1739 if err != nil {
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments