up

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package up provides the common aspects among all upwards database schema migrators. This package may be imported by its sub-packages in order to provide the Migrator[S, U] generic interface for them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migrator

type Migrator[S any, U any] interface {
	// Settler returns a settler object (with S type) without performing
	// any migration action (so, no error condition may arise). Returned
	// settler object may be employed to persist the migration results.
	Settler() S

	// MigrateUp migrates from current major version to the next major
	// version by creating relevant views in a schema such as migN
	// based on the views in a schema such as migM where N=M+1
	// considering the latest supported minor versions of those N and M
	// major versions. It may be necessary to create tables and
	// materialize data items or load them in the Golang process memory
	// in more complex scenarios, but using views is preferred as it
	// postpones the actual data copying till the last schema and
	// the settlement phase.
	// It then creates another upwards migrator object (with U type)
	// which can be used for continuing the upwards migration from
	// the next major version similarly.
	MigrateUp(ctx context.Context) (U, error)
}

Migrator of S and U is a generic interface which presents expectations from a version-dependent database schema upwards migrator object. Each upwards migrator needs a MigrateUp method which is responsible to migrate one major version upwards (staying at the latest supported minor version). The U type parameter indicates the next upwards migrator type and S type parameter indicates the settler object type. After reaching to the target major version, Settler method can be used to obtain the corresponding settler object with type S and persist the migration results.

This generic interface must be implemented by all upmigN.Migrator types. It is useful for causing compile-time errors and catching programming errors when an old upmigN package is copied, but its methods are not updated properly in order to reflect the new version.

Directories

Path Synopsis
Package upmig1 provides an upwards database schema Migrator type for major version 1 and its corresponding Adapter type which can adapt it to the version independent repo.UpMigrator[repo.SchemaSettler] interface.
Package upmig1 provides an upwards database schema Migrator type for major version 1 and its corresponding Adapter type which can adapt it to the version independent repo.UpMigrator[repo.SchemaSettler] interface.

Jump to

Keyboard shortcuts

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