migration

package module
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 11 Imported by: 1

README

psql-migration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item added in v0.3.1

type Item struct {
	ID   string
	Hash string
}

type Migration

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

func New

func New(source embed.FS) *Migration

New return new Migration object.

source must contains exactly one directory, and that directory must contains only *.sql file. each sql file must have lowercase name.

the migration is sorted by sql file name.

func (*Migration) All added in v0.3.1

func (m *Migration) All() []Item

func (*Migration) Check

func (m *Migration) Check(target string) ([]string, error)

Check the current state of the database.

will return list of migration that need to be executed.

also will return *MismatchHashError error if the database already execute a migration file but it has different hash with source.

func (*Migration) Run

func (m *Migration) Run(target string) ([]string, error)

Run the migration.

will return list of migration that executed.

also will return *MismatchHashError error if the database already execute a migration file but it has different hash with source.

func (*Migration) UnsafeMarkAsExecued added in v0.5.1

func (m *Migration) UnsafeMarkAsExecued(target string, id string) error

type MismatchHashError

type MismatchHashError struct {
	Item
	HashInDB string
}

func (*MismatchHashError) Error

func (d *MismatchHashError) Error() string

Jump to

Keyboard shortcuts

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