gmigration

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 5 Imported by: 1

README

gmigration

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilPointer defines a nil pointer argument error
	ErrNilPointer = fmt.Errorf("invalid nil pointer")
)

Functions

This section is empty.

Types

type Dao

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

Dao defines an object to the migration DAO instance responsible to manager the installed migrations.

func NewDao

func NewDao(db *gorm.DB) (*Dao, error)

NewDao instantiates a new migration DAO instance.

func (Dao) Last

func (d Dao) Last() (Record, error)

Last @todo doc

func (Dao) Up

func (d Dao) Up(model Record) (Record, error)

Up @todo doc

type Migration

type Migration interface {
	Version() int64
	Migrate() error
}

Migration defines an interface that all migrations must obey.

type Migrator

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

Migrator defines the structure of an application persistence layer migration manager.

func NewMigrator

func NewMigrator(dao *Dao) (*Migrator, error)

NewMigrator instantiates a new migration manager instance.

func (*Migrator) AddMigration

func (m *Migrator) AddMigration(migration Migration) error

AddMigration registers a migration into the migration manager

func (Migrator) Migrate

func (m Migrator) Migrate() error

Migrate execute the migration that are yet to be executed

type Record

type Record struct {
	ID uint `json:"id" xml:"id" gorm:"primaryKey"`

	Version int64 `json:"model" xml:"model"`

	CreatedAt time.Time  `json:"createdAt" xml:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt" xml:"updatedAt"`
	DeletedAt *time.Time `json:"deletedAt" xml:"deletedAt" sql:"index"`
}

Record defines the rdb record that stores a migration.

func (Record) TableName

func (Record) TableName() string

TableName defines the table name to be used to manage the migrations.

Jump to

Keyboard shortcuts

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