Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/pg/.amigo/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ package: migrations
schema-version-table: public.mig_schema_versions
shell-path: /bin/bash
sql: false
sql-syntax-highlighting: true
4 changes: 4 additions & 0 deletions pkg/amigo/execute_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (a Amigo) ExecuteMain(arg MainArg) error {
args = append(args, "-sql")
}

if a.ctx.ShowSQLSyntaxHighlighting {
args = append(args, "-sql-syntax-highlighting")
}

if a.ctx.Debug {
args = append(args, "-debug")
}
Expand Down
23 changes: 13 additions & 10 deletions pkg/entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func AmigoContextFromFlags() (*amigoctx.Context, amigo.MainArg) {
continueOnErrorFlag := flag.Bool("continue-on-error", false,
"Continue on error will not rollback the migration if an error occurs")
stepsFlag := flag.Int("steps", 1, "Number of steps to rollback")
showSQLSyntaxHighlightingFlag := flag.Bool("sql-syntax-highlighting", false,
"Print SQL statements with syntax highlighting")

// Parse flags
flag.Parse()
Expand All @@ -75,16 +77,17 @@ func AmigoContextFromFlags() (*amigoctx.Context, amigo.MainArg) {

a := &amigoctx.Context{
Root: &amigoctx.Root{
AmigoFolderPath: "",
DSN: *dsnFlag,
JSON: *jsonFlag,
ShowSQL: *showSQLFlag,
MigrationFolder: "",
PackagePath: "",
SchemaVersionTable: *schemaVersionTableFlag,
ShellPath: "",
PGDumpPath: "",
Debug: *debugFlag,
AmigoFolderPath: "",
DSN: *dsnFlag,
JSON: *jsonFlag,
ShowSQL: *showSQLFlag,
MigrationFolder: "",
PackagePath: "",
SchemaVersionTable: *schemaVersionTableFlag,
ShellPath: "",
PGDumpPath: "",
Debug: *debugFlag,
ShowSQLSyntaxHighlighting: *showSQLSyntaxHighlightingFlag,
},
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ func (d Driver) PackageName() string {
}

func (d Driver) String() string {
return string(d)
switch d {
case DriverPostgres:
return "pgx"
default:
return ""
}
}

func (d Driver) IsValid() bool {
Expand Down