Exemplo n.º 1
0
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)
		}
	}
}
Exemplo n.º 2
0
func dbVersionRun(cmd *Command, args ...string) {
	conf, err := dbConfFromFlags()
	if err != nil {
		log.Fatal(err)
	}

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

	fmt.Printf("goose: dbversion %v\n", current)
}
Exemplo n.º 3
0
func dbVersionRun(cmd *Command, args ...string) {
	confs, err := loadConfig()
	if err != nil {
		log.Fatal(err)
	}

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

		fmt.Printf("goosees: [%s:%d] dbversion %v\n", prmGroup, i, current)
	}
}
Exemplo n.º 4
0
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)
	}
}