migration

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *sqlx.DB, migrations MigrationsT, name string) ([]string, error)

Migrate run migration up on database

pass migration name to run migrate on specific migration

func MigrationCommand

func MigrationCommand(db *sqlx.DB, root string) *cobra.Command

MigrationCommand get migration command

func Rollback

func Rollback(db *sqlx.DB, migrations MigrationsT, name string) ([]string, error)

Rollback run migration down on database

pass migration name to run rollback on specific migration

func Script

func Script(db *sqlx.DB, migrations MigrationsT, name string) ([]string, error)

Script run script migration on database

pass migration name to run script on specific migration

func Seed

func Seed(db *sqlx.DB, migrations MigrationsT, name string) ([]string, error)

Seed run seed on database

pass migration name to run seed on specific migration

Types

type MigrationT

type MigrationT struct {
	Name    string
	Content string
}

func (MigrationT) In

func (m MigrationT) In(skips ...string) bool

type MigrationsT

type MigrationsT []MigrationT

func ReadDirectory

func ReadDirectory(dir string) (MigrationsT, error)

ReadDirectory read migration from file system

func (MigrationsT) Filter

func (m MigrationsT) Filter(name string) MigrationsT

Filter filter migrations by name

func (MigrationsT) Len

func (m MigrationsT) Len() int

func (MigrationsT) Less

func (m MigrationsT) Less(i, j int) bool

func (MigrationsT) Reverse added in v2.0.3

func (m MigrationsT) Reverse()

Reverse reverse array order

func (MigrationsT) Swap

func (m MigrationsT) Swap(i, j int)

Jump to

Keyboard shortcuts

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