migration

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESET     = "\033[0m"
	BOLD      = "\033[1m"
	UNDERLINE = "\033[4m"
	STRIKE    = "\033[9m"
	ITALIC    = "\033[3m"
)
View Source
const (
	RED    = "\033[31m"
	GREEN  = "\033[32m"
	YELLOW = "\033[33m"
	BLUE   = "\033[34m"
	PURPLE = "\033[35m"
	CYAN   = "\033[36m"
	GRAY   = "\033[37m"
	WHITE  = "\033[37m"
)

Variables

This section is empty.

Functions

func Formatter added in v2.2.4

func Formatter(pattern string, args ...any)

styling patterns

{R}: RESET, {B}: BOLD ,{U}: UNDERLINE ,{S}: STRIKE ,{I}: ITALIC ,{r}: RED ,{g}: GREEN ,{y}: YELLOW ,{b}: BLUE ,{p}: PURPLE ,{c}: CYAN ,{m}: GRAY ,{w}: WHITE

func Migrate

func Migrate(db *sqlx.DB, name string, files ...MigrationFile) ([]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, name string, files ...MigrationFile) ([]string, error)

Rollback run migration down on database

pass migration name to run rollback on specific migration

func Script

func Script(db *sqlx.DB, name string, files ...MigrationFile) ([]string, error)

Script run script migration on database

pass migration name to run script on specific migration

func Seed

func Seed(db *sqlx.DB, name string, files ...MigrationFile) ([]string, error)

Seed run seed on database

pass migration name to run seed on specific migration

Types

type MigrationFile added in v2.2.0

type MigrationFile struct {
	Name    string
	Content string
}

MigrationFile migration file with content

func (MigrationFile) Is added in v2.2.0

func (m MigrationFile) Is(name string) bool

Is check migration name without dash, timestamp and extension

type MigrationFiles added in v2.2.0

type MigrationFiles []MigrationFile

MigrationFiles migration file arrays

func ReadDirectory

func ReadDirectory(dir string) (MigrationFiles, error)

ReadDirectory read migration from file system

func (MigrationFiles) Filter added in v2.2.0

func (m MigrationFiles) Filter(name string) MigrationFiles

Filter filter migrations by name

func (MigrationFiles) Len added in v2.2.0

func (m MigrationFiles) Len() int

func (MigrationFiles) Less added in v2.2.0

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

func (MigrationFiles) Reverse added in v2.2.0

func (m MigrationFiles) Reverse()

Reverse reverse array order

func (MigrationFiles) Swap added in v2.2.0

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

Jump to

Keyboard shortcuts

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