package
4.18.2
Repository: https://github.com/golang-migrate/migrate.git
Documentation: pkg.go.dev

# README

httpfs

Usage

This package could be used to create new migration source drivers that uses http.FileSystem to read migration files.

Struct httpfs.PartialDriver partly implements the source.Driver interface. It has all the methods except for Open(). Embedding this struct and adding Open() method allows users of this package to create new migration sources. Example:

struct mydriver {
        httpfs.PartialDriver
}

func (d *mydriver) Open(url string) (source.Driver, error) {
	var fs http.FileSystem
	var path string
	var ds mydriver

	// acquire fs and path from url
	// set-up ds if necessary

	if err := ds.Init(fs, path); err != nil {
		return nil, err
	}
	return &ds, nil
}

This package also provides a simple source.Driver implementation that works with http.FileSystem provided by the user of this package. It is created with httpfs.New() call.

Example of using http.Dir() to read migrations from sql directory:

	src, err := httpfs.New(http.Dir("sql"))
	if err != nil {
		// do something
	}
	m, err := migrate.NewWithSourceInstance("httpfs", src, "database://url")
	if err != nil {
		// do something
	}
        err = m.Up()
	...

# Functions

New creates a new migrate source driver from a http.FileSystem instance and a relative path to migration files within the virtual FS.

# Structs

PartialDriver is a helper service for creating new source drivers working with http.FileSystem instances.