ronantakizawa/codereview-bench huggingface dataset:
Repository: hasura/graphql-engine
File: console/src/components/Services/Data/TableModify/ModifyActions.js (JavaScript)

Code before:
    column,
  };
};

const setPrimaryKeys = pks => ({
  type: SET_PRIMARY_KEYS,
  pks,
});

const addPrimaryKey = (columnIndex, pkIndex) => ({
  type: ADD_PRIMARY_KEY,
  column: columnIndex,
  pk: pkIndex,
});

const removePrimaryKey = pkIndex => ({
  type: REMOVE_PRIMARY_KEY,
  pk: pkIndex,
});

const resetPrimaryKeys = () => ({
  type: RESET_PRIMARY_KEY,
});

export const removeCheckConstraint = constraintName => (dispatch, getState) => {
  const isOk = window.confirm('Are you absolutely sure?');
  if (!isOk) return;

  const { currentTable: tableName, currentSchema } = getState().tables;

  const tableSchema = getState().tables.allSchemas.find(s => {
    return s.table_name === tableName && s.table_schema === currentSchema;
  });

  const constraint = tableSchema.check_constraints.find(
    cc => cc.constraint_name === constraintName
  );
  const upQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" drop constraint "${constraintName}"`,
    },
  };
  const downQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" add constraint "${constraintName}" ${
        constraint.check
      };`,
    },
  };

Review comment (suggestion):
use standard `getConfirmation` util fn for this with a proper message. See patterns used across the code

Code after:
  };
};

const resetColumnEdit = column => {
  return {
    type: RESET_COLUMN_EDIT,
    column,
  };
};

const setPrimaryKeys = pks => ({
  type: SET_PRIMARY_KEYS,
  pks,
});

const addPrimaryKey = (columnIndex, pkIndex) => ({
  type: ADD_PRIMARY_KEY,
  column: columnIndex,
  pk: pkIndex,
});

const removePrimaryKey = pkIndex => ({
  type: REMOVE_PRIMARY_KEY,
  pk: pkIndex,
});

const resetPrimaryKeys = () => ({
  type: RESET_PRIMARY_KEY,
});

export const removeCheckConstraint = constraintName => (dispatch, getState) => {
  const confirmMessage = `This will permanently delete the check constraint "${constraintName}" from this table`;
  const isOk = getConfirmation(confirmMessage, true, constraintName);
  if (!isOk) return;

  const { currentTable: tableName, currentSchema } = getState().tables;

  const table = findTable(
    getState().tables.allSchemas,
    generateTableDef(tableName, currentSchema)
  );

  const constraint = findTableCheckConstraint(
    getTableCheckConstraints(table),
    constraintName
  );

  const upQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" drop constraint "${constraintName}"`,
Repository: hasura/graphql-engine
File: console/src/components/Services/Data/TableModify/ModifyActions.js (JavaScript)

Code before:
  type: SET_PRIMARY_KEYS,
  pks,
});

const addPrimaryKey = (columnIndex, pkIndex) => ({
  type: ADD_PRIMARY_KEY,
  column: columnIndex,
  pk: pkIndex,
});

const removePrimaryKey = pkIndex => ({
  type: REMOVE_PRIMARY_KEY,
  pk: pkIndex,
});

const resetPrimaryKeys = () => ({
  type: RESET_PRIMARY_KEY,
});

export const removeCheckConstraint = constraintName => (dispatch, getState) => {
  const isOk = window.confirm('Are you absolutely sure?');
  if (!isOk) return;

  const { currentTable: tableName, currentSchema } = getState().tables;

  const tableSchema = getState().tables.allSchemas.find(s => {
    return s.table_name === tableName && s.table_schema === currentSchema;
  });

  const constraint = tableSchema.check_constraints.find(
    cc => cc.constraint_name === constraintName
  );
  const upQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" drop constraint "${constraintName}"`,
    },
  };
  const downQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" add constraint "${constraintName}" ${
        constraint.check
      };`,
    },
  };

  const migrationName = `drop_check_constraint_${currentSchema}_${tableName}_${constraintName}`;
  const requestMsg = 'Deleting check constraint...';
  const successMsg = 'Check constraint deleted';
  const errorMsg = 'Deleting check constraint failed';

Review comment (suggestion):
use `findTable` util fn and call the variable just `table`. Will be doing this change across the codebase sometime soon. `tableSchema` is confusing with table's postgres schema

Code after:
    type: RESET_COLUMN_EDIT,
    column,
  };
};

const setPrimaryKeys = pks => ({
  type: SET_PRIMARY_KEYS,
  pks,
});

const addPrimaryKey = (columnIndex, pkIndex) => ({
  type: ADD_PRIMARY_KEY,
  column: columnIndex,
  pk: pkIndex,
});

const removePrimaryKey = pkIndex => ({
  type: REMOVE_PRIMARY_KEY,
  pk: pkIndex,
});

const resetPrimaryKeys = () => ({
  type: RESET_PRIMARY_KEY,
});

export const removeCheckConstraint = constraintName => (dispatch, getState) => {
  const confirmMessage = `This will permanently delete the check constraint "${constraintName}" from this table`;
  const isOk = getConfirmation(confirmMessage, true, constraintName);
  if (!isOk) return;

  const { currentTable: tableName, currentSchema } = getState().tables;

  const table = findTable(
    getState().tables.allSchemas,
    generateTableDef(tableName, currentSchema)
  );

  const constraint = findTableCheckConstraint(
    getTableCheckConstraints(table),
    constraintName
  );

  const upQuery = {
    type: 'run_sql',
    args: {
      sql: `alter table "${currentSchema}"."${tableName}" drop constraint "${constraintName}"`,
    },
  };
  const downQuery = {
    type: 'run_sql',
    args: {
Repository: hasura/graphql-engine
File: cli/commands/migrate_status.go (Go)

Code before:

	return migrateStatusCmd
}

type migrateStatusOptions struct {
	EC *cli.ExecutionContext
}

func (o *migrateStatusOptions) run() (*migrate.Status, error) {
	migrateDrv, err := newMigrate(o.EC.MigrationDir, o.EC.ServerConfig.ParsedEndpoint, o.EC.ServerConfig.AdminSecret, o.EC.Logger, o.EC.Version, true)
	if err != nil {
		return nil, err
	}
	status, err := executeStatus(migrateDrv)
	if err != nil {
		return nil, errors.Wrap(err, "cannot fetch migrate status")
	}
	return status, nil
}

func printStatus(status *migrate.Status) *bytes.Buffer {
	out := new(tabwriter.Writer)
	buf := &bytes.Buffer{}
	out.Init(buf, 0, 8, 2, ' ', 0)
	w := util.NewPrefixWriter(out)
	w.Write(util.LEVEL_0, "VERSION\tSOURCE STATUS\tDATABASE STATUS\tIDENTIFIER\n")
	for _, version := range status.Index {
		w.Write(util.LEVEL_0, "%d\t%s\t%s\t%s\n",
			version,
			convertBool(status.Migrations[version].IsPresent),
			convertBool(status.Migrations[version].IsApplied),
			status.Migrations[version].Identifier,
		)
	}
	out.Flush()
	return buf
}

func convertBool(ok bool) string {
	switch ok {
	case true:
		return "Present"
	case false:
		return "Not Present"
	}
	return ""
}


Review comment (suggestion):
@eulercamposbarros Can you change `IDENTIFIER` to `NAME`.

Also, change the order to `VERSION    NAME    SOURCE STATUS    DATABASE STATUS`

Code after:

	return migrateStatusCmd
}

type migrateStatusOptions struct {
	EC *cli.ExecutionContext
}

func (o *migrateStatusOptions) run() (*migrate.Status, error) {
	migrateDrv, err := newMigrate(o.EC.MigrationDir, o.EC.ServerConfig.ParsedEndpoint, o.EC.ServerConfig.AdminSecret, o.EC.Logger, o.EC.Version, true)
	if err != nil {
		return nil, err
	}
	status, err := executeStatus(migrateDrv)
	if err != nil {
		return nil, errors.Wrap(err, "cannot fetch migrate status")
	}
	return status, nil
}

func printStatus(status *migrate.Status) *bytes.Buffer {
	out := new(tabwriter.Writer)
	buf := &bytes.Buffer{}
	out.Init(buf, 0, 8, 2, ' ', 0)
	w := util.NewPrefixWriter(out)
	w.Write(util.LEVEL_0, "VERSION\tNAME\tSOURCE STATUS\tDATABASE STATUS\n")
	for _, version := range status.Index {
		w.Write(util.LEVEL_0, "%d\t%s\t%s\t%s\n",
			version,
			status.Migrations[version].Name,
			convertBool(status.Migrations[version].IsPresent),
			convertBool(status.Migrations[version].IsApplied),
		)
	}
	out.Flush()
	return buf
}

func convertBool(ok bool) string {
	switch ok {
	case true:
		return "Present"
	case false:
		return "Not Present"
	}
	return ""
}
Repository: hasura/graphql-engine
File: server/src-lib/Hasura/RQL/DML/Select/Types.hs (Haskell)

Code before:
  | ASAgg !(ArrRelAggG v)
  deriving (Show, Eq)

traverseArrSel
  :: (Applicative f)
  => (a -> f b)
  -> ArrSelG a
  -> f (ArrSelG b)
traverseArrSel f = \case
  ASSimple arrRel -> ASSimple <$> traverse (traverseAnnSimpleSel f) arrRel
  ASAgg arrRelAgg -> ASAgg <$> traverse (traverseAnnAggSel f) arrRelAgg

type ArrSel = ArrSelG S.SQLExp

type ArrSelFldsG v = Fields (ArrSelG v)

data ColOp
  = ColOp
  { _colOp  :: S.SQLOp
  , _colExp :: S.SQLExp
  } deriving (Show, Eq)

data AnnColField
  = AnnColField
  { _acfInfo   :: !PGColumnInfo
  , _acfAsText :: !Bool
  , _acfOp     :: !(Maybe ColOp)
  } deriving (Show, Eq)

data AnnFldG v
  = FCol !AnnColField
  | FObj !(ObjSelG v)
  | FArr !(ArrSelG v)
  | FComputedField !(ComputedFieldSel v)
  | FExp !T.Text
  deriving (Show, Eq)

mkAnnColField :: PGColumnInfo -> Maybe ColOp -> AnnFldG v
mkAnnColField ci colOpM =
  FCol $ AnnColField ci False colOpM

mkAnnColFieldAsText :: PGColumnInfo -> AnnFldG v
mkAnnColFieldAsText ci =
  FCol $ AnnColField ci True Nothing

traverseAnnFld
  :: (Applicative f)
  => (a -> f b) -> AnnFldG a -> f (AnnFldG b)
traverseAnnFld f = \case
  FCol colFld -> pure $ FCol colFld
  FObj sel -> FObj <$> traverse (traverseAnnSimpleSel f) sel

Review comment (suggestion):
The context in the PR description is super helpful, and it would be nice if some of it could make it into the code, since otherwise it’s kind of hard to tell what this field is for if you’re just reading the code. Could you maybe add a short blurb about what this is for, with a note like “see #3198 for more details” at the end? Just to keep everything tied together.

Code after:
  | ASAgg !(ArrRelAggG v)
  deriving (Show, Eq)

traverseArrSel
  :: (Applicative f)
  => (a -> f b)
  -> ArrSelG a
  -> f (ArrSelG b)
traverseArrSel f = \case
  ASSimple arrRel -> ASSimple <$> traverse (traverseAnnSimpleSel f) arrRel
  ASAgg arrRelAgg -> ASAgg <$> traverse (traverseAnnAggSel f) arrRelAgg

type ArrSel = ArrSelG S.SQLExp

type ArrSelFldsG v = Fields (ArrSelG v)

data ColOp
  = ColOp
  { _colOp  :: S.SQLOp
  , _colExp :: S.SQLExp
  } deriving (Show, Eq)

data AnnColField
  = AnnColField
  { _acfInfo   :: !PGColumnInfo
  , _acfAsText :: !Bool
  -- ^ If this field is 'True', columns are explicitly casted to @text@ when fetched, which avoids
  -- an issue that occurs because we don’t currently have proper support for array types. See
  -- https://github.com/hasura/graphql-engine/pull/3198 for more details.
  , _acfOp     :: !(Maybe ColOp)
  } deriving (Show, Eq)

data AnnFldG v
  = FCol !AnnColField
  | FObj !(ObjSelG v)
  | FArr !(ArrSelG v)
  | FComputedField !(ComputedFieldSel v)
  | FExp !T.Text
  deriving (Show, Eq)

mkAnnColField :: PGColumnInfo -> Maybe ColOp -> AnnFldG v
mkAnnColField ci colOpM =
  FCol $ AnnColField ci False colOpM

mkAnnColFieldAsText :: PGColumnInfo -> AnnFldG v
mkAnnColFieldAsText ci =
  FCol $ AnnColField ci True Nothing

traverseAnnFld
  :: (Applicative f)
  => (a -> f b) -> AnnFldG a -> f (AnnFldG b)
Repository: hasura/graphql-engine
File: server/src-lib/Hasura/RQL/Types/ComputedField.hs (Haskell)

Code before:
                              , sumEncoding = TaggedObject "type" "info"
                              }
   ''ComputedFieldReturn
 )
$(makePrisms ''ComputedFieldReturn)

data ComputedFieldFunction
  = ComputedFieldFunction
  { _cffName          :: !QualifiedFunction
  , _cffInputArgs     :: !(Seq.Seq FunctionArg)
  , _cffTableArgument :: !FunctionTableArgument
  , _cffDescription   :: !(Maybe PGDescription)
  } deriving (Show, Eq)
$(deriveToJSON (aesonDrop 4 snakeCase) ''ComputedFieldFunction)

data ComputedFieldInfo
  = ComputedFieldInfo
  { _cfiName       :: !ComputedFieldName
  , _cfiFunction   :: !ComputedFieldFunction
  , _cfiReturnType :: !ComputedFieldReturn
  , _cfiComment    :: !(Maybe Text)
  } deriving (Show, Eq)
$(deriveToJSON (aesonDrop 4 snakeCase) ''ComputedFieldInfo)

onlyScalarComputedFields :: [ComputedFieldInfo] -> [ComputedFieldInfo]
onlyScalarComputedFields = filter (isJust . (^? _CFRScalar) . _cfiReturnType)

returnsSetofTable :: ComputedFieldInfo -> Bool
returnsSetofTable = isJust . (^? _CFRSetofTable) . _cfiReturnType


Review comment (suggestion):
This could be written as `filter $ has (cfiReturnType._CFRScalar)` if you make `cfiReturnType` a lens, or `filter $ has (to _cfiReturnType._CFRScalar)` if you just want to use the field accessor.

Code after:
                              , sumEncoding = TaggedObject "type" "info"
                              }
   ''ComputedFieldReturn
 )
$(makePrisms ''ComputedFieldReturn)

data ComputedFieldFunction
  = ComputedFieldFunction
  { _cffName          :: !QualifiedFunction
  , _cffInputArgs     :: !(Seq.Seq FunctionArg)
  , _cffTableArgument :: !FunctionTableArgument
  , _cffDescription   :: !(Maybe PGDescription)
  } deriving (Show, Eq)
$(deriveToJSON (aesonDrop 4 snakeCase) ''ComputedFieldFunction)

data ComputedFieldInfo
  = ComputedFieldInfo
  { _cfiName       :: !ComputedFieldName
  , _cfiFunction   :: !ComputedFieldFunction
  , _cfiReturnType :: !ComputedFieldReturn
  , _cfiComment    :: !(Maybe Text)
  } deriving (Show, Eq)
$(deriveToJSON (aesonDrop 4 snakeCase) ''ComputedFieldInfo)
$(makeLenses ''ComputedFieldInfo)

onlyScalarComputedFields :: [ComputedFieldInfo] -> [ComputedFieldInfo]
onlyScalarComputedFields = filter (has (cfiReturnType._CFRScalar))
Repository: hasura/graphql-engine
File: server/src-lib/Data/Sequence/NonEmpty.hs (Haskell)

Code before:
infixl 5 |>

newtype NESeq a
  = NESeq { unNESeq :: (a, Seq.Seq a)}
  deriving (Show, Eq)

init :: a -> NESeq a
init a = NESeq (a, Seq.empty)

head :: NESeq a -> a
head = fst . unNESeq

(|>) :: NESeq a -> a -> NESeq a
(NESeq (h, l)) |> v = NESeq (h, l Seq.|> v)

(<|) :: a -> NESeq a -> NESeq a
v <| (NESeq (h, l)) = NESeq (v, h Seq.<| l)

toSeq :: NESeq a -> Seq.Seq a
toSeq (NESeq (v, l)) = v Seq.<| l

toList :: NESeq a -> [a]
toList = F.toList . toSeq

length :: NESeq a -> Int
length = Seq.length . toSeq


Review comment (suggestion):
Might it be better to implement `Foldable` for `NESeq`? The implementation would be pretty easy, since you can get away with just implementing `foldr`, which you could do as just `foldr f v = F.foldr f v . toSeq`. Then you’d get `toList` and `length` for free, since those work on any `Foldable`. 😄 

Code after:
module Data.Sequence.NonEmpty
  ( NESeq
  , (<|)
  , (|>)
  , init
  , head
  , toSeq
  ) where

import qualified Data.Foldable as F
import qualified Data.Sequence as Seq
import           Prelude       (Eq, Show, fst, (.))

infixr 5 <|
infixl 5 |>

newtype NESeq a
  = NESeq { unNESeq :: (a, Seq.Seq a)}
  deriving (Show, Eq)

instance F.Foldable NESeq where
  foldr f v = F.foldr f v . toSeq

init :: a -> NESeq a
init a = NESeq (a, Seq.empty)

head :: NESeq a -> a
head = fst . unNESeq

(|>) :: NESeq a -> a -> NESeq a
(NESeq (h, l)) |> v = NESeq (h, l Seq.|> v)

(<|) :: a -> NESeq a -> NESeq a
v <| (NESeq (h, l)) = NESeq (v, h Seq.<| l)

toSeq :: NESeq a -> Seq.Seq a
toSeq (NESeq (v, l)) = v Seq.<| l
Repository: hasura/graphql-engine
File: cli/commands/metadata_apply.go (Go)

Code before:
	"os"

	"github.com/hasura/graphql-engine/cli"
	"github.com/pkg/errors"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

func newMetadataApplyCmd(ec *cli.ExecutionContext) *cobra.Command {
	v := viper.New()
	opts := &metadataApplyOptions{
		EC:         ec,
		actionType: "apply",
	}

	metadataApplyCmd := &cobra.Command{
		Use:   "apply",
		Short: "Apply Hasura metadata on a database",
		Example: `
		# Apply Hasura GraphQL Engine metadata present in metadata.[yaml|json] file:
		hasura metadata apply

		# Apply admin secret for Hasura GraphQL Engine:
		hasura metadata apply --admin-secret "<admin-secret>"

		# Add Hasura GraphQL Server endpoint:
		hasura metadata apply --endpoint "<endpoint>"`,
		SilenceUsage: true,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			ec.Viper = v
			return ec.Validate()
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			if opts.dryRun {
				o := &metadataDiffOptions{
					EC:     ec,
					output: os.Stdout,
				}
				filename, err := ec.GetExistingMetadataFile()
				if err != nil {
					return errors.Wrap(err, "failed getting metadata file")
				}
				o.metadata[0] = filename
				return o.run()
			}
			opts.EC.Spin("Applying metadata...")
			err := opts.run()
			opts.EC.Spinner.Stop()
			if err != nil {
				return errors.Wrap(err, "failed to apply metadata")
			}

Review comment (suggestion):
```suggestion
  # Apply metadata on a different endpoint
```

Code after:
	"os"

	"github.com/hasura/graphql-engine/cli"
	"github.com/pkg/errors"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

func newMetadataApplyCmd(ec *cli.ExecutionContext) *cobra.Command {
	v := viper.New()
	opts := &metadataApplyOptions{
		EC:         ec,
		actionType: "apply",
	}

	metadataApplyCmd := &cobra.Command{
		Use:   "apply",
		Short: "Apply Hasura metadata on a database",
		Example: `  # Apply Hasura GraphQL Engine metadata present in metadata.[yaml|json] file:
  hasura metadata apply

  # Use with admin secret:
  hasura metadata apply --admin-secret "<admin-secret>"

  # Apply metadata to an instance specified by the flag:
  hasura metadata apply --endpoint "<endpoint>"`,
		SilenceUsage: true,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			ec.Viper = v
			return ec.Validate()
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			if opts.dryRun {
				o := &metadataDiffOptions{
					EC:     ec,
					output: os.Stdout,
				}
				filename, err := ec.GetExistingMetadataFile()
				if err != nil {
					return errors.Wrap(err, "failed getting metadata file")
				}
				o.metadata[0] = filename
				return o.run()
			}
			opts.EC.Spin("Applying metadata...")
			err := opts.run()
			opts.EC.Spinner.Stop()
			if err != nil {
				return errors.Wrap(err, "failed to apply metadata")
			}
			opts.EC.Logger.Info("Metadata applied")
Repository: hasura/graphql-engine
File: cli/commands/migrate_create.go (Go)

Code before:

import (
	"io/ioutil"
	"os"
	"time"

	"github.com/ghodss/yaml"
	"github.com/hasura/graphql-engine/cli"
	"github.com/hasura/graphql-engine/cli/migrate"
	"github.com/pkg/errors"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"

	mig "github.com/hasura/graphql-engine/cli/migrate/cmd"
	log "github.com/sirupsen/logrus"
)

const migrateCreateCmdExamples = `
	# Setup migration files for the first time by introspecting a server:
  hasura migrate create "init" --from-server

	# Add admin secret for Hasura GraphQL Engine:
	hasura migrate create --admin-secret "<admin-secret>"

	# Add Hasura GraphQL Server endpoint:
	hasura migrate create --endpoint "<http-endpoint>"

	# Get SQL statements and Hasura metadata from the server:
	hasura migrate create "<migration_name>" --from-server
`

func newMigrateCreateCmd(ec *cli.ExecutionContext) *cobra.Command {
	v := viper.New()
	opts := &migrateCreateOptions{
		EC: ec,
	}

	migrateCreateCmd := &cobra.Command{
		Use:          "create [migration-name]",
		Short:        "Create files required for a migration",
		Long:         "Create sql and yaml files required for a migration",
		Example:      migrateCreateCmdExamples,
		SilenceUsage: true,
		Args:         cobra.ExactArgs(1),
		PreRunE: func(cmd *cobra.Command, args []string) error {
			ec.Viper = v
			return ec.Validate()
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			opts.name = args[0]

Review comment (suggestion):
```suggestion
  # Create the initial migration by introspecting a different server:
```

Code after:

import (
	"io/ioutil"
	"os"
	"time"

	"github.com/ghodss/yaml"
	"github.com/hasura/graphql-engine/cli"
	"github.com/hasura/graphql-engine/cli/migrate"
	"github.com/pkg/errors"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"

	mig "github.com/hasura/graphql-engine/cli/migrate/cmd"
	log "github.com/sirupsen/logrus"
)

const migrateCreateCmdExamples = `  # Setup migration files for the first time by introspecting a server:
  hasura migrate create "init" --from-server

  # Use with admin secret:
  hasura migrate create --admin-secret "<admin-secret>"

  # Setup migration files from an instance mentioned by the flag:
  hasura migrate create init --from-server --endpoint "<endpoint>"`

func newMigrateCreateCmd(ec *cli.ExecutionContext) *cobra.Command {
	v := viper.New()
	opts := &migrateCreateOptions{
		EC: ec,
	}

	migrateCreateCmd := &cobra.Command{
		Use:          "create [migration-name]",
		Short:        "Create files required for a migration",
		Long:         "Create sql and yaml files required for a migration",
		Example:      migrateCreateCmdExamples,
		SilenceUsage: true,
		Args:         cobra.ExactArgs(1),
		PreRunE: func(cmd *cobra.Command, args []string) error {
			ec.Viper = v
			return ec.Validate()
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			opts.name = args[0]
			opts.EC.Spin("Creating migration files...")
			version, err := opts.run()
			opts.EC.Spinner.Stop()
			if err != nil {
				return err