func (uc *UpCommand) Up() { // An 'Up' will walk through all migrations and apply 'default' to the target environment. // All migrations will then be walked again, applying any migrations containing the target environment. logger := gull.NewLogger(uc.Verbose) var target gull.MigrationTarget if uc.DryRun { target = gull.NewMockMigrationTarget(uc.Application, uc.Environment, logger) } else { target = gull.NewEtcdMigrationTarget(uc.EtcdHostUrl, uc.Application, uc.Environment, uc.Full, logger) } up := gull.NewUp(uc.SourceDirectory, target) err := up.Migrate() if err != nil { fmt.Printf("An error occurred while performing the migration: [%+v]\n", err) os.Exit(1) } if uc.DryRun { target.Debug() } }
func (dc *DownCommand) Down() { // A 'Down' will remove all the current configuration for an environment. // Then all migrations that were stored in etcd for that environment are applied, ignoring the latest migration. logger := gull.NewLogger(dc.Verbose) var target gull.MigrationTarget if dc.DryRun { target = gull.NewMockMigrationTarget(dc.Application, dc.Environment, logger) } else { target = gull.NewEtcdMigrationTarget(dc.EtcdHostUrl, dc.Application, dc.Environment, false, logger) } down := gull.NewDown(target) err := down.Migrate() if err != nil { fmt.Printf("An error occurred while performing the migration: [%+v]\n", err) os.Exit(1) } if dc.DryRun { target.Debug() } }