Documentation
¶
Overview ¶
Package migrate provides protocol version migration tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateScript ¶
func GenerateScript(plan *MigrationPlan) string
GenerateScript generates a migration script from a plan.
func Validate ¶
func Validate(plan *MigrationPlan, data map[string]interface{}) error
Validate validates data against the target version after migration.
Types ¶
type MigrationPlan ¶
type MigrationPlan struct {
Protocol string `json:"protocol"`
FromVersion string `json:"from_version"`
ToVersion string `json:"to_version"`
Steps []MigrationStep `json:"steps"`
Reversible bool `json:"reversible"`
}
MigrationPlan describes how to migrate between protocol versions.
func GeneratePlan ¶
func GeneratePlan(protocol, fromVer, toVer string) *MigrationPlan
GeneratePlan generates a migration plan between two protocol versions.
func Rollback ¶
func Rollback(plan *MigrationPlan) *MigrationPlan
Rollback generates a rollback plan from an existing migration plan.
type MigrationStep ¶
type MigrationStep struct {
Type string `json:"type"` // add, remove, rename, change_type
Field string `json:"field"`
NewField string `json:"new_field,omitempty"`
NewType string `json:"new_type,omitempty"`
Description string `json:"description"`
}
MigrationStep represents a single migration operation.
Click to show internal directories.
Click to hide internal directories.