versioning

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

package versioning provides standard schema versioning for Kwil databases.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetVersionTooLow = fmt.Errorf("target version is lower than current version")
)

Functions

func Upgrade

func Upgrade(ctx context.Context, db sql.TxMaker, schema string, versions map[int64]UpgradeFunc, targetVersion int64) error

Upgrade upgrades the database to the specified version. It will return an error if the database has already surpassed the specified version, or if it is not possible to upgrade to the specified version. All versions must be given as integers (e.g. 1, 2, 3, 4, 5, etc.), and are expected to be sequential. A missing version will cause an error. All upgrades will be transactional, and will be rolled back if an error occurs. All versions should start at 0. If the database is fresh, the schema will be initialized to the target version. Raw initialization at the target version can be done by providing a function for versions -1.

Types

type UpgradeFunc

type UpgradeFunc func(ctx context.Context, db sql.DB) error

UpgradeFunc is a function that can be used to upgrade a database to a specific version.

Jump to

Keyboard shortcuts

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