Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MySQLDriver driver is represented under DB_DRIVER // for MySQL. MySQLDriver = "mysql" // PostgresDriver driver is represented under // DB_DRIVER for postgres. PostgresDriver = "postgres" // ErrDBConnectionMessage is used as an error message when // no database connection could be established. ErrDBConnectionMessage = "Error establishing database connection" // ErrTableNotFoundMessage is used as an error message // when a table is missing from the installation. ErrTableNotFoundMessage = "Verbis database tables missing" )
Variables ¶
View Source
var ( // ErrCallBackMismatch is returned by AddMigration when // there has been a mismatch in the amount of callbacks // passed. Each migration should have two callbacks, // one up and one Down, or none at all. ErrCallBackMismatch = errors.New("both CallBackUp and CallBackDown must be set") )
View Source
var ( // ErrTableNotFound is returned by the driver if there are // tables missing from the installation. ErrTableNotFound = errors.New("database tables missing from verbis installation") )
View Source
var ( // Tables define the current database tables within // Verbis. Tables = []string{ "categories", "form_fields", "form_submissions", "forms", "media", "options", "password_resets", "post_categories", "post_fields", "post_options", "posts", "redirects", "roles", "user_roles", "users", } )
Functions ¶
func AddMigration ¶ added in v0.0.3
AddMigration adds a migration to the update registry which will be called when Update() is run. The version and Stage must be attached to the migration.
Types ¶
type CallBackFn ¶ added in v0.0.3
type CallBackFn func() error
CallBackFn is the function type when migrations are running up or Down.
type Migration ¶ added in v0.0.3
type Migration struct {
// The main version of the migration such as "v0.0.1"
Version string
// CallBackUp is a function called when the migration
// is going up, this can be useful when manipulating
// files and directories for the current version.
CallBackUp CallBackFn
// CallBackUp is a function called when the migration
// is going Down, this is only called if an update
// failed. And must be provided if CallBackUp is
// defined.
CallBackDown CallBackFn
// Stage defines the release stage of the migration such as
// Major, Minor or Patch,
Stage version.Stage
// The path of the MySQL file.
SQLPath string
// The path of the Postgres SQL file.
PostgresPath string
// Parsed SemVer of the Version
SemVer *sm.Version
}
Migration represents a singular migration for a single version.
type MigrationRegistry ¶ added in v0.0.3
type MigrationRegistry []*Migration
MigrationRegistry contains a slice of pointers to each migration.
func (MigrationRegistry) Len ¶ added in v0.0.3
func (m MigrationRegistry) Len() int
func (MigrationRegistry) Less ¶ added in v0.0.3
func (m MigrationRegistry) Less(i, j int) bool
func (MigrationRegistry) Sort ¶ added in v0.0.3
func (m MigrationRegistry) Sort()
Sort MigrationRegistry is a type that implements the sort.Interface interface so that versions can be sorted.
func (MigrationRegistry) Swap ¶ added in v0.0.3
func (m MigrationRegistry) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.