migration

package
v0.0.0-...-f64704c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Is waiting to be approved
	Unapproved = iota
	// Has been denied
	Denied
	// Has been depreciated
	Depreciated
	// Has been approved
	Approved
	// Is complete
	Complete
	// Is complete and was forced by Continuous Integration
	ForcedCI
	// Is currently being applied
	InProgress
	// Failed to apply
	Failed
	// Skipped application
	Skipped
	// Has been rolled back
	Rollback
)

The status states of the Migration or Migration Step

Variables

View Source
var StatusString = [10]string{
	"Unapproved",
	"Denied",
	"Depreciated",
	"Approved",
	"Complete",
	"ForcedCI",
	"InProgress",
	"Failed",
	"Skipped",
	"Rollback",
}

Functions

func CreateTables

func CreateTables() (result bool, err error)

CreateTables Create the table for the Migration table as it needs some specific handling for the time related columns than go-gorp can current handle.

func HasMigrations

func HasMigrations() (result bool, err error)

HasMigrations There are existing migrations

func IsLatest

func IsLatest(newTime string) (isLatest bool, err error)

IsLatest Return if the RFC3339 formatted timestamp is newer than the newest migration in the DB

func Print

func Print(mid int64) (err error)

Print Print a Migration and it's associated to Stdout

func Setup

func Setup(db *gorp.DbMap, projectDatabaseID int)

Setup Setup the migration tables in the management DB

func VersionExists

func VersionExists(hash string) (exists bool, err error)

VersionExists Check if the Git version has already been registered for migration

Types

type Migration

type Migration struct {
	MID                int64  `db:"mid,autoincrement,primarykey" json:"mid"`
	DB                 int    `db:"db" json:"db"`
	Project            string `db:"project" json:"project"`
	Version            string `db:"version" json:"version"`
	VersionTimestamp   string `db:"version_timestamp" json:"version_timestamp"`
	VersionDescription string `db:"version_description,size:512" json:"version_description"`
	Status             int    `db:"status" json:"status"`
	VettedBy           string `db:"vetted_by" json:"vetted_by"`
	Timestamp          string `db:"timestamp" json:"timestamp"`

	Steps   []Step `db:"-" json:"steps"`
	Sandbox bool   `db:"-" json:"-"`
}

Migration This struct stores the top migration properties.

func GetLatest

func GetLatest() (m Migration, err error)

GetLatest Return the git timestamp latest Migration from the DB

func Load

func Load(mid int64) (m *Migration, err error)

Load Load a migation from the DB using the Migration ID primary key

func LoadList

func LoadList(start int64, count int64) (migrations []Migration, end int64, total int64, err error)

LoadList Build a slice of Migrations. count has a maximum size of 50

func LoadMigrationsList

func LoadMigrationsList(mids []int64) (m []Migration, err error)

LoadMigrationsList Populate a slice of Migrations using the Migration Ids contained within mids

func LoadVersion

func LoadVersion(version string) (m *Migration, err error)

LoadVersion Load a migation from the DB using the Git version

func New

func New(p Param) (m Migration, err error)

New Migration constructor which also creates Steps and add everything to the database

func (*Migration) AddStep

func (m *Migration) AddStep(step Step)

AddStep Add a Step to the migration

func (*Migration) Insert

func (m *Migration) Insert() (err error)

Insert Insert the Migration into the Management DB

func (Migration) ToDBRow

func (m Migration) ToDBRow() test.DBRow

ToDBRow Used to convert the Migration into a unit test DBRow

func (*Migration) Update

func (m *Migration) Update() (err error)

Update Update the Migration in the Management DB

type Param

type Param struct {
	Project     string
	Version     string
	Timestamp   string
	Description string
	Forwards    mysql.SQLOperations
	Backwards   mysql.SQLOperations
	Rollback    bool
	Sandbox     bool
	VettedBy    string
}

Param A struct used to define parameters for the setup and creation of the Migration struct

type Step

type Step struct {
	SID      int64  `db:"sid,autoincrement,primarykey" json:"sid"`
	MID      int64  `db:"mid" json:"mid"`
	Op       int    `db:"op" json:"op"`
	MDID     int64  `db:"mdid" json:"mdid"`
	Name     string `db:"name" json:"name"`
	Forward  string `db:"forward" json:"forward"`
	Backward string `db:"backward" json:"backward"`
	Output   string `db:"output,size:1024" json:"output"`
	Status   int    `db:"status" json:"status"`
	VettedBy string `db:"vetted_by" json:"vetted_by"`
}

Step This struct stores the state for a step in a migration

func LoadStepsList

func LoadStepsList(sids []int64) (s []Step, err error)

LoadStepsList Populate a slice of Steps using the Step Ids contained within sids

func (*Step) Insert

func (s *Step) Insert() error

Insert Insert the Step into the Management DB

func (Step) ToDBRow

func (s Step) ToDBRow() test.DBRow

ToDBRow Used to convert the Migration into a unit test DBRow

func (*Step) Update

func (s *Step) Update() (err error)

Update Update the Step in the Management DB

func (*Step) UpdateMetadata

func (s *Step) UpdateMetadata() (err error)

UpdateMetadata Use the Step info to update the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL