Skip to content

emigrate new

The new command is used to create a new migration file in the given directory.

The migration file can be based on a template, generated by a generator plugin, or just be an empty file.

Usage

Terminal window
npx emigrate new [options] <name>

Arguments

<name>

The name of the migration. The name will be used to generate the migration filename.

The name can be provided as a single argument or as multiple arguments. If multiple arguments are provided, the arguments will be joined with a space before being passed to the filename generator (the default filename generator replaces all whitespace and non-path safe characters with underscores).

Options

-h, --help

Show command help and exit

-d, --directory <path>

The directory where the migration files are located. The given path should be absolute or relative to the current working directory.

-t, --template <path>

The template file to use for generating the migration file. The given path should be absolute or relative to the current working directory.

The template can contain a {{name}} placeholder which will be replaced with the migration name provided to the command. The generated file will have the same extension as the template file, unless the --extension option is used.

-x, --extension <ext>

The extension to use for the migration file. Unless the --template option is also specified the file will be empty.

If both the --template and --extension options are specified, the extension will override the template file extension.

Example: --extension .sql will generate a file with the .sql extension.

-p, --plugin <name>

The generator plugin to use. The generator plugin is responsible for generating the migration filename and its contents.

The name can be either a path to a module or a package name. For package names Emigrate will automatically prefix the given name with these prefixes in order:

  • @emigrate/plugin-
  • emigrate-plugin-
  • @emigrate/

And then try to load the module/package with the given name.

For example, if you want to use the emigrate-plugin-someplugin package, you can specify either emigrate-plugin-someplugin or just someplugin as the name. In case you have both a emigrate-plugin-someplugin and a someplugin package installed, the emigrate-plugin-someplugin package will be used.

-r, --reporter <name>

type: "pretty" | "json" | string
default: "pretty"

The reporter to use for listing the migrations.

The name can be either a path to a module or a package name. For package names Emigrate will automatically prefix the given name with these prefixes in order:

  • @emigrate/reporter-
  • emigrate-reporter-
  • @emigrate/

And then try to load the module/package with the given name.

For example, if you want to use the emigrate-reporter-somereporter package, you can specify either emigrate-reporter-somereporter or just somereporter as the name.

--color, --no-color

Force enable/disable colored output, option is passed to the reporter which should respect it.