The Sequelize CLI is the official command-line interface for the Sequelize ORM, providing essential tools for managing Sequelize projects. It is currently stable at version 6.6.5, with minor releases and bug fixes occurring every few months, demonstrating active maintenance. The CLI facilitates common database operations such as creating and dropping databases, managing schema migrations (applying, reverting, checking status), generating and running seed files for initial data population, and scaffolding new models, migrations, and seeders. Its key differentiator is its tight integration with the Sequelize ORM, making it the de facto tool for many Sequelize workflows, especially for projects utilizing its migration system. It supports both CommonJS and ESM configuration files, and since v6.2.0, allows for TypeScript migration files, adapting to modern JavaScript ecosystems.
npm install sequelize-cliVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a new Sequelize project using sequelize-cli, including initialization, database creation, model and migration generation, running migrations, and seeding initial data.
Review the official migration guides for each major version upgrade. Ensure your `config/config.js` (or `.json`/`.ts`) and `models/index.js` files are aligned with the new conventions. Consider initializing a new project with the target CLI version to see the expected structure.
Always prefer running `sequelize-cli` commands using `npx sequelize <command>`. This ensures that the version of `sequelize-cli` installed in your local `node_modules` is used, maintaining consistency within your project.
Ensure that `sequelize` is installed as a project dependency (`npm install sequelize`) and that its version is compatible with your `sequelize-cli` version. Consult the `sequelize-cli` GitHub repository for recommended `sequelize` ORM version compatibility.
Upgrade `sequelize-cli` to version 6.6.2 or newer, which includes a fix for parsing passwords with colons. Alternatively, ensure special characters in passwords are correctly URI-encoded if not upgrading immediately.
Always explicitly set `NODE_ENV` when running `sequelize-cli` commands, e.g., `NODE_ENV=production npx sequelize db:migrate`. You can also define a default environment in your `config/config.js` or ensure your CI/CD pipeline correctly sets this variable.
Run `npm install sequelize` or `yarn add sequelize` to add the `sequelize` package to your project.
Execute `npx sequelize db:create` to create the database as defined in your configuration.
Ensure your configuration file is correctly named (e.g., `config/config.js` for CommonJS, `config/config.mjs` for ESM, or `config/config.ts` for TypeScript) and located in the `config` directory relative to your project root. Verify your `package.json` `type` field if using ESM.
Check the `migrations` directory for new migration files. Verify their names follow the `YYYYMMDDHHMMSS-migration-name.js` format. Ensure `NODE_ENV` is set correctly to target the desired environment, and use `npx sequelize db:migrate:status` to see the current migration status.