sequelize-automate is a utility designed to automatically generate Sequelize ORM model definitions directly from an existing database schema. It supports various code styles including JavaScript, TypeScript, Egg.js, and Midway.js for the generated models. The package is currently at version 1.2.2 and appears to be actively maintained, though it does not specify a fixed release cadence. Its key differentiator is its straightforward command-line interface (CLI) that simplifies scaffolding models from an established database, reducing the manual boilerplate required when integrating Sequelize into existing projects. It supports popular SQL dialects such as MySQL, PostgreSQL, MariaDB, SQLite, and Microsoft SQL Server, requiring users to install the corresponding database driver separately. This tool is particularly useful for accelerating development in brownfield projects or when rapidly prototyping a Sequelize application against an existing data source.
npm install sequelize-automateVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `sequelize-automate` via its command-line interface (CLI) to generate TypeScript-based Sequelize models from an existing database schema. It utilizes environment variables for secure database connection details and outputs the generated files to a specified directory.
Ensure you explicitly run `npm install sequelize` and `npm install <your-database-driver>` (e.g., `npm install mysql2`) in your project.
Initialize the `Automate` class like `new Automate(database, user, password, { host, port, dialect, ...options })` ensuring all necessary connection details are provided.Specify the correct `--type` option for your project's needs. If using `--type ts`, ensure your project's `tsconfig.json` is configured correctly and you have TypeScript 4.x+ installed.
After generation, review the models and manually add any missing associations or custom logic within your application's Sequelize setup.
Run `npm install mysql2` (or `npm install -g mysql2` if using the global CLI) to install the necessary driver. Replace `mysql2` with `pg`, `mariadb`, `sqlite3`, or `tedious` for other dialects.
Verify that your database server is running and accessible from the machine running `sequelize-automate`. Double-check the `--host`, `--port`, `--user`, and `--password` parameters. Check firewall rules.
Ensure the `--user` and `--password` arguments are correct and that the user has sufficient privileges to read the database schema.