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 (
6
6
"path/filepath"
7
7
8
8
"github.com/golang-migrate/migrate/v4/source"
9
+ "github.com/golang-migrate/migrate/v4/source/iofs"
9
10
)
10
11
11
12
func init () {
12
13
source .Register ("file" , & File {})
13
14
}
14
15
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
+
15
37
func parseURL (url string ) (string , error ) {
16
38
u , err := nurl .Parse (url )
17
39
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