Documentation ¶
Overview ¶
package versioning provides standard schema versioning for Kwil databases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.