migration

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src string, dst string) error

CopyDir copies a whole directory recursively

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a single file from src to dst Code taken from https://blog.depado.eu/post/copy-files-and-directories-in-go

Types

type Item

type Item struct {
	ID       string        `json:"id"`
	Hash     string        `json:"hash"`
	DateRun  time.Time     `json:"date_run"`
	Duration time.Duration `json:"duration,string"`
}

Item holds migration item info

type Repository

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

Repository holds DB info

func NewMigrationRepository

func NewMigrationRepository(path string) (*Repository, error)

NewMigrationRepository takes a path and creates a DB repository

func (*Repository) Close

func (repo *Repository) Close() (err error)

Close closes a DB

func (*Repository) CreateMigration

func (repo *Repository) CreateMigration(migrationItem *Item) error

CreateMigration stores a migration item in DB

func (*Repository) Exists

func (repo *Repository) Exists(id string) bool

Exists checks that migrationID has been ran

func (*Repository) GetMigrationByID

func (repo *Repository) GetMigrationByID(id string) (*Item, error)

GetMigrationByID returns migration ID if it exists

func (*Repository) Open

func (repo *Repository) Open() (err error)

Open opens a DB, requires it to be closed before or it will error out

type Runner

type Runner struct{}

Runner is the actor that runs the migrations

func NewMigrationRunner

func NewMigrationRunner() *Runner

NewMigrationRunner creates default runner

func (*Runner) RunMigrations

func (mr *Runner) RunMigrations(dbPath string) error

RunMigrations executes the migrations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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