Repository: hasura/graphql-engine
File: cli/commands/migrate_create.go (Go)

Code before:
		plugins := make(metadataTypes.MetadataPlugins, 0)
		plugins = append(plugins, metadata.New(o.EC, tmpDirName))
		migrateDrv.SetMetadataPlugins(plugins)
		// fetch metadata from server
		files, err := migrateDrv.ExportMetadata()
		if err != nil {
			return 0, errors.Wrap(err, "cannot fetch metadata from server")
		}
		err = migrateDrv.WriteMetadata(files)
		if err != nil {
			return 0, errors.Wrap(err, "cannot write to tmp file")
		}

		for name := range files {
			err = createOptions.SetMetaUpFromFile(name)
			if err != nil {
				return 0, errors.Wrap(err, "cannot parse metadata from the server")
			}
		}
	}

	// create pure sql based migrations here
	if o.flags.Changed("up-sql") && o.flags.Changed("down-sql") {
		err = createOptions.SetSQLUp(o.upSQL)
		if err != nil {
			return 0, errors.Wrap(err, "up migration with SQL string could not be created")
		}

		err = createOptions.SetSQLDown(o.downSQL)
		if err != nil {
			return 0, errors.Wrap(err, "down migration with SQL string could not be created")
		}
	}

	if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version == cli.V1 && !(o.flags.Changed("up-sql") && o.flags.Changed("down-sql")) {
		// Set empty data for [up|down].yaml
		createOptions.MetaUp = []byte(`[]`)
		createOptions.MetaDown = []byte(`[]`)
	}

	if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version != cli.V1 && !(o.flags.Changed("up-sql") && o.flags.Changed("down-sql")) {
		// Set empty data for [up|down].sql
		createOptions.SQLUp = []byte(``)
		createOptions.SQLDown = []byte(``)
	}

	defer func() {
		if err != nil {
			createOptions.Delete()
		}
	}()

Review comment (suggestion):
```suggestion
			o.EC.Logger.Warn("you are creating an up migration without a down migration")
```

Code after:
		plugins := make(metadataTypes.MetadataPlugins, 0)
		plugins = append(plugins, metadata.New(o.EC, tmpDirName))
		migrateDrv.SetMetadataPlugins(plugins)
		// fetch metadata from server
		files, err := migrateDrv.ExportMetadata()
		if err != nil {
			return 0, errors.Wrap(err, "cannot fetch metadata from server")
		}
		err = migrateDrv.WriteMetadata(files)
		if err != nil {
			return 0, errors.Wrap(err, "cannot write to tmp file")
		}

		for name := range files {
			err = createOptions.SetMetaUpFromFile(name)
			if err != nil {
				return 0, errors.Wrap(err, "cannot parse metadata from the server")
			}
		}
	}

	// create pure sql based migrations here
	if o.flags.Changed("up-sql") {
		err = createOptions.SetSQLUp(o.upSQL)
		if err != nil {
			return 0, errors.Wrap(err, "up migration with SQL string could not be created")
		}
	}

	if o.flags.Changed("down-sql") {
		err = createOptions.SetSQLDown(o.downSQL)
		if err != nil {
			return 0, errors.Wrap(err, "down migration with SQL string could not be created")
		}
	}

	if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version == cli.V1 && !o.flags.Changed("up-sql") && !o.flags.Changed("down-sql") {
		// Set empty data for [up|down].yaml
		createOptions.MetaUp = []byte(`[]`)
		createOptions.MetaDown = []byte(`[]`)
	}

	if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version != cli.V1 && !o.flags.Changed("up-sql") && !o.flags.Changed("down-sql") {
		// Set empty data for [up|down].sql
		createOptions.SQLUp = []byte(``)
		createOptions.SQLDown = []byte(``)
	}

	defer func() {
		if err != nil {
			createOptions.Delete()