Sequelize-Auto

raw JSON →
0.8.7 verified Sat Apr 25 auth: no javascript maintenance

Sequelize-Auto (v0.8.7) automatically generates bare Sequelize models from an existing database. Supports MySQL, MariaDB, PostgreSQL, SQLite, and MSSQL with their respective dialect packages. It runs via CLI, reads database schemas, and outputs model files (JavaScript or TypeScript with bundled types). Last release stable but low activity; no longer installs sequelize as a dependency, requiring users to manually add both sequelize and dialect packages. Key features: customizable case conventions for models, properties, and filenames; support for excluding/including specific tables; additional model options via JSON config files.

error Error: Cannot find module 'sequelize'
cause sequelize-auto requires sequelize to be installed as a peer dependency, but it's not present.
fix
npm install sequelize
error Error: No dialect binding found for 'mysql'
cause The required dialect package (e.g., mysql2) is not installed.
fix
npm install mysql2 (or your dialect: pg, sqlite3, tedious)
error Error: getaddrinfo ENOTFOUND localhost
cause The hostname provided via -h is unreachable or incorrect.
fix
Verify your database host address and ensure it's accessible.
error SyntaxError: Unexpected token '.' in JSON at position 0
cause The --config or --additional option points to an invalid or empty JSON file.
fix
Check that the JSON file exists and is correctly formatted.
breaking sequelize-auto no longer installs sequelize as a dependency since version 0.7.0. You must manually install sequelize and the appropriate dialect package.
fix npm install sequelize mysql2 (or your dialect) before running sequelize-auto.
deprecated The --tables (-t) and --skipTables (-T) options expect table names to be provided as space-separated arguments within a single string, but passing multiple --t values is also accepted. The single-arg style is the documented and recommended approach.
fix Use -t "table1 table2" instead of -t table1 -t table2.
gotcha When using --additional (-a) to provide model options, the JSON file path must be relative to the current working directory. Absolute paths also work, but relative paths are error-prone.
fix Ensure the path is correct: --additional ./config/options.json
gotcha Generated models use Sequelize v5+ syntax (sequelize.define) but may not be fully compatible with Sequelize v6 if using legacy options. Always check your Sequelize version.
fix Update models manually or use a newer version of sequelize-auto that targets Sequelize v6.
npm install cbt-sequelize-auto
yarn add cbt-sequelize-auto
pnpm add cbt-sequelize-auto

Generates Sequelize models for the 'users' table from a MySQL database into ./models folder.

npx sequelize-auto -h localhost -d my_db -u root -x mypassword --dialect mysql -o ./models -t users