Documentation
¶
Index ¶
- Constants
- func Formatter(pattern string, args ...any)
- func InitMigration(db *sqlx.DB) error
- func Migrate(db *sqlx.DB, stage string, files ...File) ([]string, error)
- func MigrationCommand(db *sqlx.DB, root, ext string, autExec ...string) *cobra.Command
- func Rollback(db *sqlx.DB, files ...File) ([]string, error)
- type File
- func (file File) Content() string
- func (file File) Extension() string
- func (file File) Is(name string) bool
- func (file File) Migrate(db *sqlx.DB, stage string, migrated ...string) (bool, error)
- func (file File) MustSkip(skips ...string) bool
- func (file File) Name() string
- func (file File) RealName() string
- func (file File) Rollback(db *sqlx.DB, migrated ...string) (bool, error)
- func (file File) Scripts(stage string) ([]string, error)
- func (file File) Timestamp() int64
- type Files
- type Migration
- type Migrations
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
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 InitMigration ¶ added in v2.5.0
InitMigration prepare database to run migrations
func MigrationCommand ¶
MigrationCommand get migration command
Types ¶
type File ¶ added in v2.5.0
type File struct {
// contains filtered or unexported fields
}
File migration file
func NewFile ¶ added in v2.5.0
NewFile create new migration file from content
file name must full with extension
func (File) Migrate ¶ added in v2.5.0
Migrate migrate file stage, return true if migrate or false if file already migrated
type Files ¶ added in v2.5.0
type Files []File
Files migration file list
type Migrations ¶ added in v2.5.0
type Migrations []Migration
func Migrated ¶ added in v2.5.0
func Migrated(db *sqlx.DB) (Migrations, error)
Migrated get migrated items
func StageMigrated ¶ added in v2.5.0
func StageMigrated(db *sqlx.DB, stage string) (Migrations, error)
StageMigrated get migrated items for stage
func (Migrations) GroupByFile ¶ added in v2.5.0
func (migrations Migrations) GroupByFile() map[string][]string
Group migration by file
func (Migrations) GroupByStage ¶ added in v2.5.0
func (migrations Migrations) GroupByStage() map[string][]string
Group migration by stage
func (Migrations) Names ¶ added in v2.5.0
func (migrations Migrations) Names() []string
Get migration file names
Click to show internal directories.
Click to hide internal directories.