dbump

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const MigrationDelimiter = `--- apply above / rollback below ---`

MigrationDelimiter separates apply and rollback queries inside a migration step/file.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, m Migrator, l Loader) error

Run the Migrator with migration queries provided by the Loader.

Types

type DiskLoader

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

DiskLoader can load migrations from disk/OS.

func NewDiskLoader

func NewDiskLoader(path string) *DiskLoader

NewDiskLoader instantiates a new DiskLoader.

func (*DiskLoader) Load

func (fs *DiskLoader) Load() ([]*Migration, error)

Load is a method for Loader interface.

type EmbedLoader

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

EmbedLoader can load migrations from embed.FS.

func NewEmbedLoader

func NewEmbedLoader(fs embed.FS, path string) *EmbedLoader

NewEmbedLoader instantiates a new EmbedLoader.

func (*EmbedLoader) Load

func (efs *EmbedLoader) Load() ([]*Migration, error)

Load is a method for Loader interface.

type Loader

type Loader interface {
	Load() ([]*Migration, error)
}

Loader returns migrations to be applied on a DB.

type Migration

type Migration struct {
	ID       int    // ID of the migration, unique, positive, starts from 1.
	Name     string // Name of the migration
	Apply    string // Apply query
	Rollback string // Rollback query
}

Migration represents migration step that will be runned on DB.

type Migrator

type Migrator interface {
	Lock(ctx context.Context) error
	Unlock(ctx context.Context) error

	Version(ctx context.Context) (version int, err error)
	SetVersion(ctx context.Context, version int) error

	Exec(ctx context.Context, query string, args ...interface{}) error
}

Migrator represents DB over which we will run migration queries.

type MigratorClickHouse

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

MigratorClickHouse to migrate ClickHouse.

func NewMigratorClickHouse

func NewMigratorClickHouse(db *sql.DB) *MigratorClickHouse

NewMigratorClickHouse instantiates new MigratorClickHouse.

func (*MigratorClickHouse) Exec

func (ch *MigratorClickHouse) Exec(ctx context.Context, query string, args ...interface{}) error

Exec is a method for Migrator interface.

func (*MigratorClickHouse) Lock

func (ch *MigratorClickHouse) Lock(ctx context.Context) error

Lock is a method for Migrator interface.

func (*MigratorClickHouse) SetVersion

func (ch *MigratorClickHouse) SetVersion(ctx context.Context, version int) error

SetVersion is a method for Migrator interface.

func (*MigratorClickHouse) Unlock

func (ch *MigratorClickHouse) Unlock(ctx context.Context) error

Unlock is a method for Migrator interface.

func (*MigratorClickHouse) Version

func (ch *MigratorClickHouse) Version(ctx context.Context) (version int, err error)

Version is a method for Migrator interface.

type MigratorMySQL

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

MigratorMySQL to migrate MySQL.

func NewMigratorMySQL

func NewMigratorMySQL(db *sql.DB) *MigratorMySQL

NewMigratorMySQL instantiates new MigratorMySQL.

func (*MigratorMySQL) Exec

func (my *MigratorMySQL) Exec(ctx context.Context, query string, args ...interface{}) error

Exec is a method for Migrator interface.

func (*MigratorMySQL) Lock

func (my *MigratorMySQL) Lock(ctx context.Context) error

Lock is a method for Migrator interface.

func (*MigratorMySQL) SetVersion

func (my *MigratorMySQL) SetVersion(ctx context.Context, version int) error

SetVersion is a method for Migrator interface.

func (*MigratorMySQL) Unlock

func (my *MigratorMySQL) Unlock(ctx context.Context) error

Unlock is a method for Migrator interface.

func (*MigratorMySQL) Version

func (my *MigratorMySQL) Version(ctx context.Context) (version int, err error)

Version is a method for Migrator interface.

type MigratorPostgres

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

MigratorPostgres to migrate Postgres.

func NewMigratorPostgres

func NewMigratorPostgres(db *sql.DB) *MigratorPostgres

NewMigratorPostgres instantiates new MigratorPostgres.

func (*MigratorPostgres) Exec

func (pg *MigratorPostgres) Exec(ctx context.Context, query string, args ...interface{}) error

Exec is a method for Migrator interface.

func (*MigratorPostgres) Lock

func (pg *MigratorPostgres) Lock(ctx context.Context) error

Lock is a method for Migrator interface.

func (*MigratorPostgres) SetVersion

func (pg *MigratorPostgres) SetVersion(ctx context.Context, version int) error

SetVersion is a method for Migrator interface.

func (*MigratorPostgres) Unlock

func (pg *MigratorPostgres) Unlock(ctx context.Context) error

Unlock is a method for Migrator interface.

func (*MigratorPostgres) Version

func (pg *MigratorPostgres) Version(ctx context.Context) (version int, err error)

Version is a method for Migrator interface.

Jump to

Keyboard shortcuts

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