Documentation ¶
Overview ¶
Package pgmigrate implements a minimalistic migration library for postgres. See README for more information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
Schema: "migrations",
Table: "migrations",
}
DefaultConfig should be used by most users.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Schema is the name of the postgres schema the migrations table is stored in. Schema string // Table is the name of the migrations table. Table string }
Config allows to customize pgmigrate. However, most users should use the DefaultConfig.
func (*Config) Migrate ¶
func (c *Config) Migrate(db *sql.DB, ms Migrations) (Migrations, error)
Migrate validates ms, and on success applies any ms that has not already been executed. The return value is either an error, or a list of all migrations that were applied.
type Migrations ¶
type Migrations []Migration
Migrations holds a list of migrations sorted by id. The first migration needs to have ID 1, and each following ID has to be incremented by 1.
func LoadMigrations ¶
func LoadMigrations(dirFS http.FileSystem) (Migrations, error)
LoadMigrations loads all migration files named {{id}}_{{description}}.sql inside dirFS and returns them or an error. The returned Migrations are guaranteed to be sorted, but no validated.
func (Migrations) Less ¶
func (m Migrations) Less(i, j int) bool
Less is part of the sort.Interface.
func (Migrations) Valid ¶
func (m Migrations) Valid() error
Valid returns an error if m holds an invalid migration list.