Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 1.6 KB

README.md

File metadata and controls

68 lines (48 loc) · 1.6 KB

dbump

build-img pkg-img version-img

Go database schema migrator library (See cristalhq/dbumper tool).

Rationale

Most of the tools related to database migrations are bloated with the questionable features and dependecies. However, in most of the cases migrations are just files with queries to run. This library does this.

Features

  • Simple.
  • Clean and tested code.
  • Supports fs.FS and go:embed.
  • ZigZag mode to better test migrations.
  • Dependency-free (database connectors are optional).
  • Supported databases:
    • Postgres
    • MySQL
    • ClickHouse
    • or your own!

See GUIDE.md for more details.

Install

Go version 1.17+

go get github.com/cristalhq/dbump

Example

ctx := context.Background()

cfg := dbump.Config{
	Migrator: dbump_pg.NewMigrator(db),
	Loader:   dbump.NewFileSysLoader(embed, "/"),
	Mode:     dbump.ModeApplyAll,
}

err := dbump.Run(ctx, cfg)
if err != nil {
	panic(err)
}

Also see examples: example_test.go.

Documentation

See these docs.

License

MIT License.