(cmd *cobra.Command, args []string)
| 27 | } |
| 28 | |
| 29 | func (h *MigrateHandler) makeMigrationManager(cmd *cobra.Command, args []string) (*sql.MigrationManager, error) { |
| 30 | opts := append([]driver.OptionsModifier{ |
| 31 | driver.WithConfigOptions( |
| 32 | configx.SkipValidation(), |
| 33 | configx.WithFlags(cmd.Flags())), |
| 34 | driver.DisableValidation(), |
| 35 | driver.DisablePreloading(), |
| 36 | driver.SkipNetworkInit(), |
| 37 | }, h.dOpts...) |
| 38 | if len(args) > 0 { |
| 39 | opts = append(opts, driver.WithConfigOptions( |
| 40 | configx.WithValue(config.KeyDSN, args[0]), |
| 41 | )) |
| 42 | } |
| 43 | |
| 44 | d, err := driver.New( |
| 45 | cmd.Context(), |
| 46 | opts...) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | if len(d.Config().DSN()) == 0 { |
| 51 | _, _ = fmt.Fprintln(cmd.ErrOrStderr(), "No DSN provided. Please provide a DSN as the first argument or set the DSN environment variable.") |
| 52 | return nil, cmdx.FailSilently(cmd) |
| 53 | } |
| 54 | |
| 55 | return d.Migrator(), nil |
| 56 | } |
| 57 | |
| 58 | func (h *MigrateHandler) MigrateSQLUp(cmd *cobra.Command, args []string) (err error) { |
| 59 | p, err := h.makeMigrationManager(cmd, args) |
no test coverage detected