Documentation ¶
Index ¶
Constants ¶
View Source
const ( StatusRollingBack = "rolling back" StatusApplying = "applying" StatusApplied = "applied" )
View Source
const (
MigrationExtension = ".sql"
)
Variables ¶
View Source
var ( NoErrAlreadyApplied = errors.New("migration has already been applied") NoErrDoesNotExist = errors.New("migration does not exist") )
Functions ¶
func GetMigrationNamesFromFilenames ¶ added in v1.0.4
func NormalizeQuery ¶
Types ¶
type Migration ¶
type Migration struct { // ID will contain the database-assigned auto-incremented ID of the migration ID int64 `json:"id" yaml:"id"` // Name contains the name of the migration derived from the migration file name Name string `json:"name" yaml:"name"` // Up contains a SQL command that should result in a up-version shift of the database schema Up string `json:"up" yaml:"up"` // Down contains a SQL command that should result in a down-version shift of the database schema Down string `json:"down" yaml:"down"` // Error contains any error that happened Error *string `json:"error" yaml:"error"` // Status contains the status of the migration Status string `json:"status" yaml:"status` // AppliedAt holds the timestamp when the migration was successfully applied to the database AppliedAt *time.Time `json:"applied_at" yaml:"applied_at"` // CreatedAt holds the timestamp when the migration was initialised in the database CreatedAt *time.Time `json:"created_at" yaml:"created_at"` }
func NewFromFile ¶
type Migrations ¶ added in v1.0.2
type Migrations []*Migration
func NewFromDirectory ¶ added in v1.0.4
func NewFromDirectory(directoryPath string) (Migrations, error)
func (Migrations) Len ¶ added in v1.0.2
func (m Migrations) Len() int
Len implements the sort.Interface
func (Migrations) Less ¶ added in v1.0.2
func (m Migrations) Less(i, j int) bool
Less implements the sort.Interface
func (Migrations) Swap ¶ added in v1.0.2
func (m Migrations) Swap(i, j int)
Swap implements the sort.Interface
Click to show internal directories.
Click to hide internal directories.