-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from alexisvisco/1-remove-driver-dependencies
1 remove driver dependencies
- Loading branch information
Showing
57 changed files
with
1,676 additions
and
1,113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
.idea | ||
migrations | ||
.amigo | ||
!example/pg/.amigo | ||
!example/pg/migrations |
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 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/alexisvisco/amigo/pkg/amigo" | ||
"github.com/alexisvisco/amigo/pkg/amigoctx" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// migrateCmd represents the up command | ||
var migrateCmd = &cobra.Command{ | ||
Use: "migrate", | ||
Short: "Apply the database", | ||
Run: wrapCobraFunc(func(cmd *cobra.Command, am amigo.Amigo, args []string) error { | ||
if err := cmdCtx.ValidateDSN(); err != nil { | ||
return err | ||
} | ||
|
||
return am.ExecuteMain(amigo.MainArgMigrate) | ||
}), | ||
} | ||
|
||
// rollbackCmd represents the down command | ||
var rollbackCmd = &cobra.Command{ | ||
Use: "rollback", | ||
Short: "Rollback the database", | ||
Run: wrapCobraFunc(func(cmd *cobra.Command, am amigo.Amigo, args []string) error { | ||
if err := cmdCtx.ValidateDSN(); err != nil { | ||
return err | ||
} | ||
|
||
return am.ExecuteMain(amigo.MainArgRollback) | ||
}), | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(rollbackCmd) | ||
rootCmd.AddCommand(migrateCmd) | ||
|
||
registerBase := func(cmd *cobra.Command, m *amigoctx.Migration) { | ||
cmd.Flags().StringVar(&m.Version, "version", "", | ||
"Apply a specific version format: 20240502083700 or 20240502083700_name.go") | ||
cmd.Flags().BoolVar(&m.DryRun, "dry-run", false, "Run the migrations without applying them") | ||
cmd.Flags().BoolVar(&m.ContinueOnError, "continue-on-error", false, | ||
"Will not rollback the migration if an error occurs") | ||
cmd.Flags().DurationVar(&m.Timeout, "timeout", amigoctx.DefaultTimeout, "The timeout for the migration") | ||
} | ||
|
||
registerBase(migrateCmd, cmdCtx.Migration) | ||
|
||
registerBase(rollbackCmd, cmdCtx.Migration) | ||
rollbackCmd.Flags().IntVar(&cmdCtx.Migration.Steps, "steps", 1, "The number of steps to rollback") | ||
} |
Oops, something went wrong.