diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-12-17 21:32:40 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-12-17 21:32:40 +0700 |
| commit | 6a2d049cc385d825cb2c48f7c36d96990da92c6c (patch) | |
| tree | 5db3a0d6c2dd9f8190f5880a0d05c31a62dc9a97 /lib/sql/client.go | |
| parent | 0c5ed9573fec93cbf31e4778c981c61d7decdf4a (diff) | |
| download | pakakeh.go-6a2d049cc385d825cb2c48f7c36d96990da92c6c.tar.xz | |
sql: use the options MigrationDir if the argument fs is nil
If case the file-system argument is not provided, the function will
assume that the migration script is stored in the MigrationDir which
defined in ClientOptions.
Diffstat (limited to 'lib/sql/client.go')
| -rw-r--r-- | lib/sql/client.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sql/client.go b/lib/sql/client.go index ac88cb23..3ab7ccef 100644 --- a/lib/sql/client.go +++ b/lib/sql/client.go @@ -102,6 +102,13 @@ func (cl *Client) FetchTableNames() (tableNames []string, err error) { // SQL file name that has been executed and the timestamp. // func (cl *Client) Migrate(fs http.FileSystem) (err error) { + if fs == nil { + if len(cl.MigrationDir) == 0 { + return nil + } + fs = http.Dir(cl.MigrationDir) + } + root, err := fs.Open("/") if err != nil { return fmt.Errorf("Migrate: %w", err) |
