예제 #1
0
파일: cmd_redo.go 프로젝트: l3msh0/goosees
func redoRun(cmd *Command, args ...string) {
	confs, err := loadConfig()
	if err != nil {
		log.Fatal(err)
	}

	for _, conf := range confs {
		current, err := goose.GetDBVersion(conf)
		if err != nil {
			log.Fatal(err)
		}

		previous, err := goose.GetPreviousDBVersion(conf.MigrationsDir, current)
		if err != nil {
			log.Fatal(err)
		}

		if err := goose.RunMigrations(conf, conf.MigrationsDir, previous); err != nil {
			log.Fatal(err)
		}

		if err := goose.RunMigrations(conf, conf.MigrationsDir, current); err != nil {
			log.Fatal(err)
		}
	}
}
예제 #2
0
func Down() {
	var dirpath string = viper.GetString("GOOSE_DIR")
	cfg := newGooseConf()
	version, err := goose.GetMostRecentDBVersion(dirpath)
	if err != nil {
		log.Fatal(err)
	}

	previous, err := goose.GetPreviousDBVersion(dirpath, version)
	if err != nil {
		log.Fatal(err)
	}
	err = goose.RunMigrations(cfg, dirpath, previous)
	if err != nil {
		log.Fatal(err)
	}
}
예제 #3
0
파일: cmd_down.go 프로젝트: robinjha/clair
func downRun(cmd *Command, args ...string) {

	conf, err := dbConfFromFlags()
	if err != nil {
		log.Fatal(err)
	}

	current, err := goose.GetDBVersion(conf)
	if err != nil {
		log.Fatal(err)
	}

	previous, err := goose.GetPreviousDBVersion(conf.MigrationsDir, current)
	if err != nil {
		log.Fatal(err)
	}

	if err = goose.RunMigrations(conf, conf.MigrationsDir, previous); err != nil {
		log.Fatal(err)
	}
}