versioning

package module
v0.0.0-...-a1f7910 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: MIT Imports: 7 Imported by: 2

README

versioning

GoDoc Go Report Card

Generic in code database versioning package. Used for upgrading db schemas in databases used by client applications even when closed source.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FncVersion

type FncVersion func(tx *sqlx.Tx) (err error)

FncVersion is the function signature for doing a single version schema update. It takes a transaction object and should return an error on any type of failure. The service itself will take responsibility for commit or rollback.

type Repository

type Repository interface {
	Version() (version int, err error)
	SetVersion(tx *sqlx.Tx, version int) (err error)
	DB() *sqlx.DB
	Service() string
}

Repository holds a database specific implementation for the generic versioning service.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is our versioning Service.

func New

func New(
	db *sqlx.DB, serviceName string, logger log.Logger, debug bool,
) (s *Service, err error)

New tries to create and return a new versioning service for provided database connection.

func (*Service) Add

func (s *Service) Add(version int, fnc FncVersion)

Add allows one to add a version upgrade function with the version number to the versioning service.

func (*Service) Run

func (s *Service) Run() (version int, err error)

Run checks and if needed upgrades the database returning the latest version of the database to which it upgraded and potentially an error if it occurred.

func (*Service) Version

func (s *Service) Version() (version int, err error)

Version returns the current version of the database for the service.

Directories

Path Synopsis
Package postgresql provides the needed specifics to support the generic versioning service.
Package postgresql provides the needed specifics to support the generic versioning service.
Package sqlite3 provides the needed specifics to support the generic versioning service.
Package sqlite3 provides the needed specifics to support the generic versioning service.
Package sqlserver provides the needed specifics to support the generic versioning service.
Package sqlserver provides the needed specifics to support the generic versioning service.

Jump to

Keyboard shortcuts

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