migration

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

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 17 Imported by: 0

README

SQLite Migration

The aim of this project is to provide a simple way to manage, various sql file for an SQLite database. The migration process is pretty simple, and the file here only automate some of it.

Documentation

Index

Constants

View Source
const (
	// InitialVersion represents the value of the very first version, an empty database.
	InitialVersion = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrApplyFile

type ErrApplyFile struct {
	Filename string
	Sha1Hash string
	Err      error
}

func (ErrApplyFile) Error

func (err ErrApplyFile) Error() string

func (ErrApplyFile) Unwrap

func (err ErrApplyFile) Unwrap() error

type ErrApplyFileRead

type ErrApplyFileRead struct {
	Filename string
	Err      error
}

func (ErrApplyFileRead) Error

func (err ErrApplyFileRead) Error() string

func (ErrApplyFileRead) Unwrap

func (err ErrApplyFileRead) Unwrap() error

type ErrApplyFileTemplate

type ErrApplyFileTemplate struct {
	Filename string
	Err      error
}

func (ErrApplyFileTemplate) Error

func (err ErrApplyFileTemplate) Error() string

func (ErrApplyFileTemplate) Unwrap

func (err ErrApplyFileTemplate) Unwrap() error

type ErrCreateTable

type ErrCreateTable struct {
	Err       error
	TableName string
}

func (ErrCreateTable) Error

func (err ErrCreateTable) Error() string

func (ErrCreateTable) Unwrap

func (err ErrCreateTable) Unwrap() error

type ErrTrackingInfo

type ErrTrackingInfo struct {
	Err       error
	TableName string
}

func (ErrTrackingInfo) Error

func (err ErrTrackingInfo) Error() string

func (ErrTrackingInfo) Unwrap

func (err ErrTrackingInfo) Unwrap() error

type ErrUnknownVersion

type ErrUnknownVersion string

func (ErrUnknownVersion) Error

func (err ErrUnknownVersion) Error() string

type FSOpener

type FSOpener = fs.FS

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Manager

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

Manager will manage a set of migration file and apply them to the database

func New

func New(dir, tableName string, fs FSOpener) *Manager

New returns a new manager

func (*Manager) DBVersion

func (mng *Manager) DBVersion(db *sql.DB) (string, error)

DBVersion returns the version of migration in the given db

func (*Manager) FS

func (mng *Manager) FS() FSOpener

func (*Manager) FuncMap

func (mng *Manager) FuncMap() template.FuncMap

func (*Manager) HasTrackingTable

func (mng *Manager) HasTrackingTable(db *sql.DB) bool

func (*Manager) Init

func (mng *Manager) Init(db *sql.DB, author string) (ver string, didInit bool, err error)

Init will ensure that the initial tables for the file correctly initialized, it returns the current database version

func (*Manager) LatestVersion

func (mng *Manager) LatestVersion() (string, error)

func (*Manager) Log

func (mng *Manager) Log() Logger

func (*Manager) SetLog

func (mng *Manager) SetLog(l Logger)

func (*Manager) TableName

func (mng *Manager) TableName() string

func (*Manager) Upgrade

func (mng *Manager) Upgrade(db *sql.DB, author string) (startingVersion string, newVersion string, err error)

Upgrade will upgrade the db file to the latest schema

func (*Manager) VersionFile

func (mng *Manager) VersionFile() string

func (*Manager) Versions

func (mng *Manager) Versions() ([]string, error)

Directories

Path Synopsis
cmd
Package schema provide a general interface to obtain schema information from a database
Package schema provide a general interface to obtain schema information from a database
sqlite
Package sqlite provides the schema interface for an SQLite database.
Package sqlite provides the schema interface for an SQLite database.

Jump to

Keyboard shortcuts

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