migrate

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(db *bun.DB, sql string, isTx bool, splitter string) (err error)

func GenerateDown

func GenerateDown(upSql string) string

func GenerateDownLine

func GenerateDownLine(up string) (down string)

func Name

func Name(s string) (name string, comment string, isUp bool, isTx bool, ok bool)

func ReadSql

func ReadSql(f fs.FS, path string) (sql string, err error)

Types

type DownGenerator

type DownGenerator struct {
	Process func(string) bool
	Command string
	// contains filtered or unexported fields
}

func NewDownGenerator

func NewDownGenerator() *DownGenerator

type Migration

type Migration struct {
	bun.BaseModel

	Id         int64     `bun:",pk,autoincrement"`
	Name       string    `bun:",notnull"`
	Comment    string    `bun:",notnull"`
	IsTx       bool      `bun:",notnull"`
	UpHash     string    `bun:",notnull"`
	DownHash   string    `bun:",notnull"`
	UpSql      string    `bun:"-"`
	DownSql    string    `bun:",notnull"`
	GroupId    int64     `bun:",notnull"`
	MigratedAt time.Time `bun:",notnull"`

	Up   func() error `bun:"-"`
	Down func() error `bun:"-"`
	// contains filtered or unexported fields
}

func (*Migration) AutoGenerateDown

func (o *Migration) AutoGenerateDown()

func (*Migration) DownHashIsValid

func (o *Migration) DownHashIsValid() bool

func (Migration) Error

func (o Migration) Error() error

func (*Migration) GenerateDown

func (o *Migration) GenerateDown()

func (*Migration) IsApplied

func (o *Migration) IsApplied() bool

func (*Migration) Lost

func (o *Migration) Lost() bool

func (*Migration) PreviewDown

func (o *Migration) PreviewDown() string

func (*Migration) SetApplied

func (o *Migration) SetApplied(groupId int64)

func (*Migration) SetFuncs

func (o *Migration) SetFuncs(db *bun.DB, splitter string)

func (*Migration) SetUnapplied

func (o *Migration) SetUnapplied()

func (Migration) String

func (o Migration) String() string

func (*Migration) UpHashIsValid

func (o *Migration) UpHashIsValid() bool

type Migrations

type Migrations []*Migration

func (Migrations) Applied

func (o Migrations) Applied() (applied Migrations)

func (*Migrations) AutoGenerateDown

func (o *Migrations) AutoGenerateDown()

func (Migrations) Count

func (o Migrations) Count() int

func (Migrations) Last

func (o Migrations) Last() *Migration

func (Migrations) LastGroup

func (o Migrations) LastGroup() (l Migrations)

func (Migrations) LastGroupId

func (o Migrations) LastGroupId() (lastGroupId int64)

func (*Migrations) Load

func (o *Migrations) Load(f fs.FS) error

func (Migrations) SetFuncs

func (o Migrations) SetFuncs(db *bun.DB, splitter string)

func (Migrations) SortAsc

func (o Migrations) SortAsc()

func (Migrations) SortDesc

func (o Migrations) SortDesc()

func (Migrations) Unapplied

func (o Migrations) Unapplied() (unapplied Migrations)

type Migrator

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

func NewMigrator

func NewMigrator(db *bun.DB) *Migrator

func (*Migrator) AppliedMigrations

func (o *Migrator) AppliedMigrations() (l Migrations)

func (*Migrator) AppliedMigrationsCount

func (o *Migrator) AppliedMigrationsCount() int

func (*Migrator) Forget

func (o *Migrator) Forget() (err error)

func (*Migrator) Init

func (o *Migrator) Init() (err error)

func (*Migrator) Load

func (o *Migrator) Load(fs fs.FS) (err error)

func (*Migrator) Migrate

func (o *Migrator) Migrate() (err error)

func (*Migrator) Migrations

func (o *Migrator) Migrations() Migrations

func (*Migrator) MigrationsCount

func (o *Migrator) MigrationsCount() int

func (*Migrator) Reset

func (o *Migrator) Reset() (err error)

func (*Migrator) Rollback

func (o *Migrator) Rollback() (err error)

func (*Migrator) RollbackLast

func (o *Migrator) RollbackLast() (err error)

func (*Migrator) Status

func (o *Migrator) Status() string

func (*Migrator) UnappliedMigrations

func (o *Migrator) UnappliedMigrations() (l Migrations)

func (*Migrator) UnappliedMigrationsCount

func (o *Migrator) UnappliedMigrationsCount() int

func (*Migrator) WithAutoDownSql

func (o *Migrator) WithAutoDownSql(v bool) *Migrator

func (*Migrator) WithMarkAppliedOnSuccess

func (o *Migrator) WithMarkAppliedOnSuccess(v bool) *Migrator

func (*Migrator) WithRollbackLost

func (o *Migrator) WithRollbackLost(v bool) *Migrator

func (*Migrator) WithSaveDownSql

func (o *Migrator) WithSaveDownSql(v bool) *Migrator

func (*Migrator) WithSplitter

func (o *Migrator) WithSplitter(v string) *Migrator

func (*Migrator) WithTableName

func (o *Migrator) WithTableName(v string) *Migrator

Jump to

Keyboard shortcuts

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