Documentation ¶
Index ¶
- Constants
- Variables
- func CompareVersionStr(left string, right string) bool
- func CreateVersionTable(url string, verbose bool, schema string) error
- func EqualsVersionFullAndShort(leftVersionShort *VersionShort, rightVersionShort *Version) bool
- func EqualsVersionShort(leftVersionShort *VersionShort, rightVersionShort *VersionShort) bool
- func ExecuteMigrationString(url string, sqlString string, verbose bool) error
- func GenerateConsecutiveDowngradesMigrationString(flavor string, path string, schema string, currentVersion *VersionShort, ...) (string, error)
- func GenerateMigrationString(node *MigrationNode) string
- func GenerateMigrationStringFromVersionShortRange(init bool, flavor string, path string, schema string, ...) (string, error)
- func GenerateTransactionString(flavor string, sql string) (string, error)
- func GetCreateVersionTableQueryString(schema string) string
- func GetDatabaseConnection(url string, verbose bool) (*sql.DB, string, error)
- func GetUpdateVersionQueryString(init bool, currentVersion *VersionShort, version *VersionShort, schema string) string
- func GetVersionTableName(schema string) string
- func ParseVersionShortRange(versionShortRange string) (*VersionShort, *VersionShort, error)
- func PrintMigrationTree(root *MigrationNode, currentVersion *VersionShort)
- func TransverseMigrationTree(root *MigrationNode, fn TransverseFunction)
- type MigrationFailedFile
- type MigrationFile
- type MigrationNode
- type TransverseFunction
- type Version
- type VersionShort
Constants ¶
View Source
const ( Postgresql string = "postgres" Mysql = "mysql" SqlServer = "sqlserver" Oracle = "oracle" )
Variables ¶
View Source
var SqlConnectionUrlRegex = regexp.MustCompile("^([a-z]+?):\\/\\/(.+?):(.+?)@([\\w:\\.]+?)\\/([\\w_]+?)([\\?].+?)?$")
View Source
var VersionRangeRegex = regexp.MustCompile("^([U|V][\\d_\\.]+?):([U|V][\\d_\\.]+?)$")
View Source
var VersionRegex = regexp.MustCompile("([V|U])([\\d_\\.]+?)__(.+?)(\\.\\w{2,6})")
View Source
var VersionShortRegex = regexp.MustCompile("^([U|V])([\\d_\\.]+?)$")
Functions ¶
func CompareVersionStr ¶
CompareVersionStr If left is smaller than the right one, then true.
If both are the same, then true.
Example:
CompareVersionStr("1_0", "0_1") -> false CompareVersionStr("1_0", "1_10") -> true CompareVersionStr("1_0_5", "1_10") -> true
func EqualsVersionFullAndShort ¶
func EqualsVersionFullAndShort(leftVersionShort *VersionShort, rightVersionShort *Version) bool
func EqualsVersionShort ¶
func EqualsVersionShort(leftVersionShort *VersionShort, rightVersionShort *VersionShort) bool
func ExecuteMigrationString ¶
func GenerateMigrationString ¶
func GenerateMigrationString(node *MigrationNode) string
func GenerateMigrationStringFromVersionShortRange ¶
func GenerateMigrationStringFromVersionShortRange(init bool, flavor string, path string, schema string, currentVersion *VersionShort, leftVersion *VersionShort, rightVersion *VersionShort) (string, error)
func GetDatabaseConnection ¶
func GetUpdateVersionQueryString ¶
func GetUpdateVersionQueryString(init bool, currentVersion *VersionShort, version *VersionShort, schema string) string
func GetVersionTableName ¶
func ParseVersionShortRange ¶
func ParseVersionShortRange(versionShortRange string) (*VersionShort, *VersionShort, error)
func PrintMigrationTree ¶
func PrintMigrationTree(root *MigrationNode, currentVersion *VersionShort)
func TransverseMigrationTree ¶
func TransverseMigrationTree(root *MigrationNode, fn TransverseFunction)
Types ¶
type MigrationFailedFile ¶
type MigrationFile ¶
type MigrationNode ¶
type MigrationNode struct { File *MigrationFile UndoMigrationNode *MigrationNode NextMigrationNode *MigrationNode PrevMigrationNode *MigrationNode }
func BuildMigrationTree ¶
func BuildMigrationTree(dir string) (*MigrationNode, *[]*MigrationFailedFile, error)
func BuildMigrationTreeFromPath ¶
func BuildMigrationTreeFromPath(dir string) (*MigrationNode, *[]*MigrationFailedFile, error)
func FindMigrationNode ¶
func FindMigrationNode(root *MigrationNode, version *VersionShort) *MigrationNode
type TransverseFunction ¶
type TransverseFunction func(node *MigrationNode) error
type Version ¶
type Version struct { Prefix string // Prefix: can be `U` or `V` Version string // Version: semantic version with _ Description string // Description: description of the migration Suffix string // Suffix: file extension }
func FindPreviousVersion ¶
func FindPreviousVersion(root *MigrationNode, targetVersion *VersionShort) *Version
func ParseVersion ¶
type VersionShort ¶
func GetVersionShortFromFull ¶
func GetVersionShortFromFull(version *Version) *VersionShort
func ParseVersionShort ¶
func ParseVersionShort(versionShort string) (*VersionShort, error)
Click to show internal directories.
Click to hide internal directories.