LinuxCommandLibrary

sequelize

TLDR

Initialize sequelize

$ npx sequelize-cli init
copy
Create model
$ npx sequelize-cli model:generate --name [User] --attributes [name:string,email:string]
copy
Run migrations
$ npx sequelize-cli db:migrate
copy
Undo last migration
$ npx sequelize-cli db:migrate:undo
copy
Create seed
$ npx sequelize-cli seed:generate --name [demo-user]
copy
Run seeds
$ npx sequelize-cli db:seed:all
copy
Create migration
$ npx sequelize-cli migration:generate --name [add-column]
copy

SYNOPSIS

sequelize-cli command [options]

DESCRIPTION

sequelize-cli manages Sequelize ORM projects. It handles models, migrations, and seeds.
Initialization creates project structure. Config, models, migrations, and seeders directories.
Models define database tables. Attributes specify columns and types.
Migrations version database schema. Up and down functions for changes.
Seeds populate initial data. Development and testing data setup.

PARAMETERS

init

Initialize project.
model:generate
Create model.
db:migrate
Run migrations.
db:migrate:undo
Revert migration.
seed:generate
Create seed file.
db:seed:all
Run all seeds.
migration:generate
Create migration.
--name NAME
Model/migration name.
--attributes ATTRS
Model attributes.

CAVEATS

Node.js ORM. Database-specific syntax may vary. Migration ordering is important.

HISTORY

Sequelize is a Node.js ORM supporting PostgreSQL, MySQL, SQLite, and others. The CLI provides scaffolding and migration tools.

SEE ALSO

node(1), npm(1), knex(1)

Copied to clipboard