Skip to content

CrowderSoup/gormgrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gormgrate

Build & Test

Managed manual migrations for GORM

Usage

gormgrate provides a MigrationFile interface. Each of your migrations must satisfy this interface.

type MigrationFile interface {
	Up(*gorm.DB) error
	Down(*gorm.DB) error
	Name() string
}

You can find an example migration in this repo at examples/migration_example.go.

Once you've created a migration, you use gormgate in your project like so (it's assumed you already have db initialized):

files := gormgrate.MigrationFile{
    NewExampleMigration(),
}
migrator, err := gormgrate.NewMigrator(db, true, files)
if err != nil {
    log.Fatal(err)
}

err = migrator.RunMigrations()
if err != nil {
	log.Fatal(err)
}

About

Managed manual migrations for GORM

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors