Skip to content

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

License

Notifications You must be signed in to change notification settings

cristalhq/dbump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

03a4023 · Jun 30, 2022

History

42 Commits
Jun 4, 2022
Jun 25, 2022
Jun 25, 2022
Jun 15, 2022
Jun 27, 2022
Jun 24, 2022
Jun 24, 2022
Oct 11, 2021
Jun 26, 2022
Jun 26, 2022
Jun 30, 2022
Jun 30, 2022
Jun 22, 2022
Oct 18, 2021
Jun 25, 2022
Jun 23, 2022
Jun 30, 2022

Repository files navigation

dbump

build-img pkg-img reportcard-img coverage-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.16+

go get github.com/cristalhq/dbump

Example

ctx := context.Background()

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

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

Also see examples: example_test.go.

Documentation

See these docs.

License

MIT License.