github.com/friesencr/pop/v6@v6.1.6/soda/cmd/migrate_up.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/friesencr/pop/v6"
     5  	"github.com/spf13/cobra"
     6  )
     7  
     8  var migrationStepUp int
     9  var noSchema bool
    10  
    11  var migrateUpCmd = &cobra.Command{
    12  	Use:   "up",
    13  	Short: "Apply one or more of the 'up' migrations.",
    14  	RunE: func(cmd *cobra.Command, args []string) error {
    15  		mig, err := pop.NewFileMigrator(migrationPath, getConn())
    16  		if err != nil {
    17  			return err
    18  		}
    19  		_, err = mig.UpTo(!noSchema, migrationStepUp)
    20  		return err
    21  	},
    22  }
    23  
    24  func init() {
    25  	migrateCmd.AddCommand(migrateUpCmd)
    26  	migrateUpCmd.Flags().IntVarP(&migrationStepUp, "step", "s", 0, "Number of migrations to apply. Use 0 to apply all pending.")
    27  }