-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor migrate commands - remove create command and goto command, refactor migration to use transaction to be able roolback when a file with multiple statements fail In case of goto we removed because it do the same of next. Create: we need a command that just create a file? Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * lint fix Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * fix tests Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * try to fix called twice on migration Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * Revert "try to fix called twice on migration" This reverts commit 8733843. * try to fix called twice on migration Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * update migration Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * migration v3 Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * backwards compatible Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * lint Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * fix query Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev> * set docker registry path (#432) * set docker registry path fixed: #431 Signed-off-by: Avelino <t@avelino.xxx> * fixed travis PR test Signed-off-by: Avelino <t@avelino.xxx> * upgrade all go dep packages Signed-off-by: Avelino <t@avelino.xxx> Co-authored-by: Avelino <t@avelino.xxx>
- Loading branch information
Showing
24 changed files
with
690 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/gosidekick/migration/v3" | ||
"github.com/spf13/cobra" | ||
// postgres driver for migrate | ||
_ "gopkg.in/mattes/migrate.v1/driver/postgres" | ||
"gopkg.in/mattes/migrate.v1/migrate" | ||
) | ||
|
||
// downCmd represents the down command | ||
var downCmd = &cobra.Command{ | ||
Use: "down", | ||
Short: "Roll back all migrations", | ||
Long: `Roll back all migrations`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
verifyMigrationsPath(path) | ||
timerStart = time.Now() | ||
pipe := migrate.NewPipe() | ||
go migrate.Down(pipe, urlConn, path) | ||
ok := writePipe(pipe) | ||
printTimer() | ||
if !ok { | ||
os.Exit(-1) | ||
Use: "down", | ||
Short: "Roll back all migrations", | ||
Long: `Roll back all migrations`, | ||
PreRunE: checkTable, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
n, executed, err := migration.Run(context.Background(), path, urlConn, "down") | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Fprintf(os.Stdout, "exec migrations located in %v\n", path) | ||
fmt.Fprintf(os.Stdout, "executed %v migrations\n", n) | ||
for _, e := range executed { | ||
fmt.Fprintf(os.Stdout, "%v SUCCESS\n", e) | ||
} | ||
return nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.