Skip to content

Commit

Permalink
Merge pull request #6 from alexisvisco/1-remove-driver-dependencies
Browse files Browse the repository at this point in the history
1-remove-driver-dependencies
  • Loading branch information
alexisvisco authored May 26, 2024
2 parents 8790c85 + 9358526 commit 0ee9811
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
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

0 comments on commit 0ee9811

Please sign in to comment.