dbmigration

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const UP = "UP"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cassandra

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

func NewCassandra

func NewCassandra(d *datastore.Cassandra) *Cassandra

NewCassandra returns a new Cassandra instance

func (*Cassandra) FinishMigration

func (c *Cassandra) FinishMigration() error

FinishMigration completes the migration

func (*Cassandra) GetAllMigrations

func (c *Cassandra) GetAllMigrations(app string) (upMigrations, downMigrations []int)

GetAllMigrations retrieves migration versions

func (*Cassandra) LastRunVersion

func (c *Cassandra) LastRunVersion(app, method string) (lv int)

LastRunVersion retrieves the last run migration version

func (*Cassandra) Run

func (c *Cassandra) Run(m Migrator, app, name, method string, logger log.Logger) error

Run executes a migration

type DBDriver

type DBDriver interface {
	/*
		Run creates the migration tracker table
		checks if dirty migrations exists for an `app`
		then executes either Up or Down migration based on the method parameter
	*/
	Run(mig Migrator, app, name, method string, logger log.Logger) error

	/*
		LastRunVersion fetches the last max version run
	*/
	LastRunVersion(app, method string) int

	/*
		GetAllMigrations fetches all the migrations run for an `app`
		separates out UP and DOWN migrations
	*/
	GetAllMigrations(app string) (upMigration []int, downMigration []int)

	/*
		FinishMigration stores all the migrations run into the database if, there is no error in any of the migrations
		error in one migration leads to not storing any of the migrations in the database
	*/
	FinishMigration() error
}

type GORM

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

func NewGorm

func NewGorm(d *gorm.DB) *GORM

NewGorm return an new GORM instance

func (*GORM) FinishMigration

func (g *GORM) FinishMigration() error

FinishMigration completes the migration

func (*GORM) GetAllMigrations

func (g *GORM) GetAllMigrations(app string) (upMigration, downMigration []int)

GetAllMigrations retrieves all migrations

func (*GORM) LastRunVersion

func (g *GORM) LastRunVersion(app, method string) (lv int)

LastRunVersion retrieves the last run migration version

func (*GORM) Run

func (g *GORM) Run(m Migrator, app, name, methods string, logger log.Logger) error

Run executes a migration

type Migrator

type Migrator interface {
	Up(db *datastore.DataStore, logger log.Logger) error
	Down(db *datastore.DataStore, logger log.Logger) error
}

type Mongo

type Mongo struct {
	datastore.MongoDB
	// contains filtered or unexported fields
}

func NewMongo

func NewMongo(m datastore.MongoDB) *Mongo

NewMongo returns a new Mongo instance

func (*Mongo) FinishMigration

func (md *Mongo) FinishMigration() error

FinishMigration completes the migration

func (*Mongo) GetAllMigrations

func (md *Mongo) GetAllMigrations(app string) (upMigrations, downMigrations []int)

GetAllMigrations retrieves all migrations

func (*Mongo) LastRunVersion

func (md *Mongo) LastRunVersion(app, method string) int

LastRunVersion retrieves the last run migration version

func (*Mongo) Run

func (md *Mongo) Run(m Migrator, app, name, method string, logger log.Logger) (err error)

Run executes a migration

type Redis

type Redis struct {
	datastore.Redis
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(r datastore.Redis) *Redis

NewRedis returns a new Redis instance

func (*Redis) FinishMigration

func (r *Redis) FinishMigration() error

FinishMigration completes the migration

func (*Redis) GetAllMigrations

func (r *Redis) GetAllMigrations(app string) (upMigrations, downMigrations []int)

GetAllMigrations retrieves all migrations

func (*Redis) LastRunVersion

func (r *Redis) LastRunVersion(app, method string) int

LastRunVersion retrieves the last run migration version

func (*Redis) Run

func (r *Redis) Run(mig Migrator, app, name, method string, logger log.Logger) error

Run executes a migration

type YCQL

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

func NewYCQL

func NewYCQL(d *datastore.YCQL) *YCQL

NewYCQL return a new YCQL instance

func (*YCQL) FinishMigration

func (y *YCQL) FinishMigration() error

FinishMigration completes the migration

func (*YCQL) GetAllMigrations

func (y *YCQL) GetAllMigrations(app string) (upMigration, downMigration []int)

GetAllMigrations retrieves all migrations

func (*YCQL) LastRunVersion

func (y *YCQL) LastRunVersion(app, method string) int

LastRunVersion retrieves the last run migration version

func (*YCQL) Run

func (y *YCQL) Run(m Migrator, app, name, method string, logger log.Logger) error

Run executes a migration

Jump to

Keyboard shortcuts

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