migrate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

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