Skip to content

tetzng/miglint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

miglint

miglint is a lightweight CLI to lint migration files named for golang-migrate. It only inspects files directly under a migrations directory (no recursion) and reports duplicate, naming, and operational rule violations.

Install

go install github.com/tetzng/miglint/cmd/miglint@latest

Usage

miglint -path ./migrations [options]

Required:

  • -path : directory containing migration files

Optional flags:

  • -ext : extension filter; match final ext (sql) or full ext part (sql.gz) (leading dot is allowed, e.g. .sql)
  • -enforce-ext (default: false) : with -ext, treat migration-like files (incl. .up/.down without ext) whose extension differs as errors
  • -no-gaps (default: false) : require contiguous version numbers
  • -digits (default: 0) : fix VERSION width; 0 disables the check
  • -require-down (default: false) : require both up and down for every version
  • -strict-name-match (default: false) : require NAME and ExtPart to match between up/down of the same version
  • -strict-pattern (default: false) : error on candidate files (numeric/migration-like, incl. .up/.down without ext) that don’t match the migrate pattern

Notes:

  • Symlinked files are linted if they point to regular files.

Examples

  • Basic lint:
miglint -path ./db/migrations
  • Strict SQL-only, no gaps, up/down required:
miglint -path ./db/migrations \
  -ext sql -enforce-ext=true \
  -require-down=true \
  -strict-name-match=true \
  -no-gaps=true

About

a lightweight CLI to lint migration files named for `golang-migrate`

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages