Documentation
¶
Index ¶
- Variables
- type Executor
- type Logger
- type Migrate
- func (m *Migrate) Apply(ctx context.Context, version int64) (err error)
- func (m *Migrate) Down(ctx context.Context) (err error)
- func (m *Migrate) Up(ctx context.Context) (err error)
- func (m *Migrate) Version(ctx context.Context) (version *Version, err error)
- func (m *Migrate) Versions() (versions []Version)
- type Migration
- type Statements
- type Version
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidNoTx = fmt.Errorf("migrate: migrations that disable transactions must have only one statement")
)
var ( // StdLog is the log.Printf function from the standard library StdLog = log.Printf )
Functions ¶
This section is empty.
Types ¶
type Executor ¶ added in v0.2.6
type Executor interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}
Executor executes statements in a database
type Migrate ¶
type Migrate struct {
// contains filtered or unexported fields
}
Migrate manages database migrations
func New ¶
New creates a new Migrate with the given database and versions.
If the provided logger function is not `nil` additional information will be logged during the migrations apply or discard.
func NewWithFiles ¶
NewWithFiles is like new but takes a fs.Fs as a source for migration files. Only files within the 1st level of the provided path matching the `(\d+)_(\w+)\.(apply|discard)\.sql` pattern will be added to the Migrate catalog.
func (*Migrate) Apply ¶
Apply either rolls forward or backwards the migrations to the specified version
type Migration ¶
type Migration struct { Version int64 Name string Apply Statements Discard Statements }
Migration represents a database migration apply and discard statements
type Statements ¶ added in v0.2.6
Statements are set of SQL statements that either apply or discard a migration