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
2
votes
2 answers

Sequelize CLI migration error Cannot read properties of undefined (reading 'type')

I'm running sequelize-cli db:migrate to initialize a migration, but this happens Sequelize CLI \[Node: 19.6.1, CLI: 6.6.0, ORM: 6.28.1\] Loaded configuration file "config\\config.js". == 20230221223939-aluno: migrating ======= ERROR: Cannot read…
Khiuta
  • 21
  • 2
2
votes
2 answers

How to update a record and update include many records relationship by foreignKey in sequelize use db postgres

I create an API that updates a record associated with a foreign key if I just put a value to items so I want it to return remove other values that I don't put if I edit some value in items so I want it to return the value that I edited if I put…
Raibann
  • 21
  • 4
2
votes
2 answers

How to configure sequelize, and sequelize-cli to work with typescript

How to Configure Sequelize and Sequelize-CLI to work with TypeScript I have a project to maintain using sequelize and typescript and I tried as hard as possible to configure them, but I couldn't. I cannot generate models using the cli, and sometimes…
2
votes
0 answers

sequelizerc Error Cannot use import statement outside a module

I am trying to run seeders on my sequelize typescript project .sequelizerc import '@babel/register'; import path from 'path'; const settings = { config: path.resolve('src', 'config', 'index.js'), 'migrations-path': path.resolve('src', 'data',…
2
votes
2 answers

Error running sequelize seeder on typescript based setup

I want to use sequelize seeders and migrations on my express api and currently all the models are written in typescript using sequelize-typescript I tried adding my first seeder file using typescript and I get an error when running…
2
votes
0 answers

Sequelize Association - belongsToMany giving TypeError ("Dependency name must be given as a not empty string")

I am using sequelize with express, these are my models (that i've been debugging for almost 2hrs). I'm trying to implement Many to many from my table User to Requirement through UserRequirement. User -> UserRequirement <- Requirement Requirement…
2
votes
1 answer

NodeJs - Is there a way to put imageToBase64 const inside create method from Sequelize while uploading picture?

I have this route below working fine routes.post("/product/new", adminAuth, upload.single("picture"), (req,res) => { var {title, code, price, amount, supplier } = req.body async function convertImage(){ return await…
aleffaso
  • 33
  • 3
2
votes
3 answers

const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes) - TypeError: require(...) is not a function

I am beginner in web dev and trying to create a project using Mysql, Node.js with Express. Facing this TypeError issue while using Sequalize. Can someone please explain it to me and help me find a solution? "sequelize": "^6.19.0" "sequelize-cli":…
2
votes
0 answers

1:N relationship query to find one in Sequelize.js not working properly

I have started learning sequelize.js with node.js and having hard time defining relationships between models. I am trying to create 1:N relationship between users and roles tables i.e. many users can have same role. Problem When I query user model…
2
votes
1 answer

Sequelize bulk insert error with polygon column

I have the following model with a column of type polygon module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.createTable('p_zones', { id: { allowNull: false, autoIncrement: true, …
Diego
  • 23
  • 2
  • 3
2
votes
0 answers

Sequelize generates empty migrations

Assuming my ES6 JavaScript project with Sequelize, I have three different model files. My sequelize.rc config file is well configured, but when I want to generate the very first migration files for my brand new models with…
Maxime Lafarie
  • 2,172
  • 1
  • 22
  • 41
2
votes
1 answer

How do I add conditions in sub-sub child models in sequelize which should impact my parent Model in findAndCountAll?

In sequelize, I want to add a condition in findAndCountAll call in sub-sub child models. If the condition is false, it should impact on parent models and findAndCountAll should return array length 0. Currently, just that sub-sub child model's array…
kamran186
  • 111
  • 1
  • 5
2
votes
2 answers

Sequelize errno: 150 "Foreign key constraint is incorrectly formed"

I have a problem with migrating two tables with relationships. I want to add a foreign key to product.js migration, but it is not working. If I will run the application with await sequelize.sync(); database creating well. How to fix this issue? I…
entithat
  • 324
  • 6
  • 18
2
votes
1 answer

How to generate migrations automatically from Sequelize models

I just started to program with node.js. I needed an ORM so I used Sequelize library. I wrote my User model as follows and I need to create a migration for it. Is there any way to create migrations automatically from the Sequelize models instead of…
2
votes
0 answers

How to create models using sequelize and typescript?

I have sequelize-cli installed globally. When I run the command sequelize model:create --name User --attributes name:string,email:string,password:string it creates the model at models/user.js and migration at…
Kshitij Bajracharya
  • 811
  • 2
  • 14
  • 37