Questions tagged [sequelize-cli]

The Sequelize Command Line Interface (CLI) supports for migrations and seeders.

The Sequelize Command Line Interface (CLI) supports for migrations and seeders.

With migrations and seeders it's possible to transfer an existing database into another state and vice versa: those state transitions are saved in migration storage and seeder storage accordingly, which describe the way how to get to the new state and how to revert the changes in order to get back to the old state.

Useful links:


Related tags:

499 questions
4
votes
1 answer

SequelizeJS migration: Adding multiple foreign keys to the same model?

When using the sequelize cli utility's migration feature, new foreign keys can be created by adding a new column. However, I'm running into an error when trying to create multiple foreign keys to the same model. The foreign key names produced by…
jorgenkg
  • 4,140
  • 1
  • 34
  • 48
4
votes
3 answers

Sequelize-CLI Add Column to Existing Model

I have been reading through a good amount of the sequelize-cli documentation and can't seem to figure out how to add a column to an existing model that I have in place. I have a model called, models/team.js and want to add a column named role_name…
cphill
  • 5,596
  • 16
  • 89
  • 182
4
votes
1 answer

What is the command to generate migration script from existing sequelize models?

I've created models using the following command. $ node_modules/.bin/sequelize model:create --name XYZ --attributes "....." But by mistake I deleted the folder containing migration script. Now I want to generate this script again. I tried using…
sairaj
  • 157
  • 4
  • 14
3
votes
1 answer

In sequelize connection I am getting operation timeout error. How to fix this issue

I am using Sequelize ORM for connecting databases using NODE JS and PostgreSQL. When I request concurrently to the server it's throwing an error ConnectionAcquireTimeoutError [SequelizeConnectionAcquireTimeoutError]: Operation timeout. So, I search…
3
votes
1 answer

How to structure seqeulize migration files for many-to-many association

What do you have to put in your migration files (and model files) to create a M:N association in sequelize? I suspect I specifically mean, what references need to be set, and what do the required keys in those objects mean, but I'm not 100% sure…
philolegein
  • 1,099
  • 10
  • 28
3
votes
1 answer

Sequelize Migration Add Array Column

I'm trying to add a column via migration to a particular table. The goal is to add a column type of an array that include enum values 1 Attempt: await queryInterface.addColumn( 'Locations', 'tags', { type:…
3
votes
0 answers

Instantiating a Sequelize connection multiple times in a project: is this a bad idea?

My goal with this question is to achieve, in a safe and sustainable way, working VS Code intellisense with Sequelize model definitions in my node.js (not typescript) project. Sequelize models can be constructed via hooks, or by extending the Model…
defraggled
  • 1,014
  • 11
  • 13
3
votes
1 answer

how to set mysql datetype length with sequelize-cli

sequelize/CLI version: "sequelize-cli": "^6.2.0","sequelize": "^6.3.3" i'm using this to generate a mysql user table npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string expect to generate an…
paul xiao
  • 33
  • 3
3
votes
1 answer

Can't use prototypes or instance methods in Sequelize v6

I am using passport.js in conjunction with Sequelize version 6.3.3. The model file was scaffolded using the sequelize-cli and I have the following problems: I am unable to use either the instance methods or prototype methods that I have defined on…
3
votes
1 answer

Sequelize migration doesnot read dotenv variable if I don't run it from root directory. why?

This is what I did require('dotenv').config() in the config file set .sequelizerc in the root directory like below set .sequelie file to point config, migrations, models, seeds directory from root directory ran npx seuqlie-cli db:migrate form root…
byyoung
  • 327
  • 3
  • 10
3
votes
2 answers

Unhandled rejection SequelizeDatabaseError: Unknown column 'createdAt' in 'field list'

I am working on ORM data base and I don't have createdAt column in table and I am using Sequelize ORM for db interaction. I am getting the following error: Unhandled rejection SequelizeDatabaseError: Unknown column 'createdAt' in 'field list'
Rakesh
  • 793
  • 4
  • 22
3
votes
1 answer

TypeError: Modelname.findById is not a function with sequelize nodejs

I want to find value from table with respect to Id passed in api. When using findByID to find one record I am getting below errro. TypeError: Modelname.findById is not a function
Rakesh
  • 793
  • 4
  • 22
3
votes
8 answers

ERROR: "Please install sqlite3 package manually" when I execute "sequelize db:migrate"

I'm trying to create a sample app, using this article: https://arjunphp.com/restful-api-using-async-await-node-express-sequelize/ But when a try to execute database migration with sequenze-cli on sqlite, a have always the same…
3
votes
1 answer

Run Sequelize migration files from separate third-party Node module?

I am working on third-party NODE module which deal with sending emails and storing them in DB, so let's call it mail-module. In order for someone to use its functionalities, it should be enough to import it in his project and use its functions for…
milosdju
  • 783
  • 12
  • 27
3
votes
2 answers

SequelizeEagerLoadingError: (parent) is not associated to (child)!

I am building an application using sequelize. I currently have 3 tables; a User, a Tour, and a Location. The Location has a n:1 relationship with the Tour. The Tour has a n:1 relationship with the user. Without the User association, the other two…
Jen Pirrone
  • 53
  • 1
  • 7