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 file, a template plugin, or just be an empty file.
Usage
npx emigrate new [options] [<name>]pnpm emigrate new [options] [<name>]yarn emigrate new [options] [<name>]bunx --bun emigrate new [options] [<name>]{ "scripts": { "emigrate": "emigrate" }, "dependencies": { "@emigrate/cli": "*" }}deno task 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 the name argument is not provided, you’ll be prompted for it.
The name can contain any characters and any whitespace. Illegal file name characters and whitespace will be replaced with the --joiner option (default is _) and any consecutive such characters will be replaced with a single occurrence of the “joiner”.
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.
If not provided via the command line option or configuration file, the directory will be prompted for.
-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, --prefix <name>
type: ”timestamp" | "timestamp-local" | "iso" | "iso-local" | "unix" | "unix-ms" | "numeric" | "none”
default: timestamp
The type of prefix to use for the new migration file.
If you want a custom prefix function you can specify that in your configuration file using the prefix option.
-e, --extension <ext>
type: string
default: .js
The extension to use for the migration file. If not provided, and the --template option is specified its file extension will be used.
If both the --template and --extension options are specified, the extension will override the template file extension.
If none of --template or --extension are specified, the extension to use will be prompted for if there are registered template plugins that can generate migration files with different extensions, otherwise it will default to .js.
Example: --extension .sql will generate a file with the .sql extension.
-j, --joiner <string>
type: string
default: _
The string to use to join the prefix and the name of the migration file. It’s also used for replacing whitespace and characters that are not allowed in filenames in the name.
-p, --plugin <name>
Template plugins to use. A template plugin can generate the contents for the new migration file depending on the chosen extension (default file extension is .js).
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.
--color, --no-color
Force enable/disable colored output, option is passed to the reporter which should respect it.