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
1
vote
1 answer

How to export and using sequelize models nodejs

This is my node model using sequelize: ` "use strict"; const { Model } = require("sequelize"); module.exports = (sequelize, DataTypes) => { class User extends Model { static associate(models) { User.hasMany(sequelize.models.Article, { …
1
vote
1 answer

NodeJS Sequelize DataTypes.DOUBLE(10,2) is returning integer

DataTypes.DOUBLE(10,2) or DataTypes.DECIMAL(10,2) returns integer if there is no decimal value after ".". Only returns decimal if there is any value other then zero. Migration 'use strict'; module.exports = { async up(queryInterface, Sequelize) { …
1
vote
4 answers

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

I'm running npx sequelize-cli db:migrate to create the table in the database and returns the following message: Sequelize CLI [Node: 18.9.1, CLI: 6.5.1, ORM: 6.20.1] ERROR: Cannot find "/src/db/migrations/config/config.json". Have you run…
dev user
  • 41
  • 1
  • 8
1
vote
1 answer

how to write migrations to add foreignkey to already existing tables in sequelize

I have this already created two tables called User and Profile. This is how my model for User looks like.. const Sequelize = require("sequelize"); const db = require("../db"); const User = db.define("User", { id: { type: Sequelize.INTEGER, …
1
vote
1 answer

ERROR: Cannot find "/app/config/config.json". Have you run "sequelize init"?

Dockerfile FROM node:16.14.2-alpine as build WORKDIR /myapp COPY package*.json ./ RUN npm ci COPY . ./ ENV NODE_ENV='dev' RUN npm run build FROM build EXPOSE 3000 CMD ["node"] // list reduced to one item // .sequelizerc const path =…
myselfmiqdad
  • 2,518
  • 2
  • 18
  • 33
1
vote
0 answers

Webpack errors while using sequelize with next.js?

I am importing a model in pages/api/submitAllegationApi.js and creating a new entry there. Strangely enough there's no error when I use the 'api/submitAllegationApi' alone. Once I call another api route, and then use 'api/submitAllegationApi' again,…
shardul
  • 117
  • 7
1
vote
2 answers

Sequelize TypeError: Cannot read properties of undefined (reading 'split')

I am trying to update a sequelize model partially that contains a string array value separated by semicolons. languages: { type: Sequelize.STRING, allowNull: false, get() { if (this.getDataValue('languages') === null) { …
1
vote
0 answers

Must declare the scalar variable "@0" error come during INSERT query in SSMS V18.10

I am getting this error while executing INSERT query which is generated from sequelize. INSERT INTO [table_name] ([fname], [lname], [userid], [createdAt],[updatedAt], [version]) OUTPUT INSERTED.[id], INSERTED.[fname], INSERTED.[lname],…
Venkatesh
  • 11
  • 2
1
vote
0 answers

Sequelize query with nested array object json

I have data stored in a Postgres 11 table, one of the columns has a json object as it follows: id data client_id 1 JSON BR_123 { "shed": false, "transactions": [ { "id": 1, "value": 5000, …
1
vote
1 answer

Sequelize-cli creates model with extending Model class

When I create a new model with the sequelize-cli it automatically creates a model by extending the Model class. I would like to create models with the sequelize.define syntax. How can I change this? Is this a configuration I can change? Command npx…
Fabio
  • 62
  • 8
1
vote
0 answers

Sequelize-cli migration still using previously renamed files in addition off new files

I recently started to work on an old project for my job with Sequelize 4 (first time using Sequelize for me). I make a mistake in migration file name before a migration, so I renamed this file and then, my migration run the good file AND the old…
1
vote
1 answer

Sequelize many-to-many updating junction table

I don't see how i can update an junction table with multiple id's. So i want to update a junction table so that those rows with ids that are missing leave, and new ones are created. This is my setup ActorFilm.belongsTo(models.Actor, { foreignKey:…
too29bad
  • 38
  • 1
  • 5
1
vote
1 answer

Migration with Sequelize CLI to DigitalOcean Postgres Database Throwing SSL Error

Connecting to my my DigitalOcean database with Sequelize works fine when I'm not migrating. For example, attempting to create a new table works just fine; the code below successfully connects and creates a new table. sequelize = new…
1
vote
2 answers

Nodejs actions testing via Github not working, because Dialect needs to be explicitly supplied

So for this project I need to automate my testing. I can run the tests locally without a problem; they all pass. But as soon as I do a pull request, the tests fail in Github actions. I want to make sure the tests also pass on Github actions. Error…
1
vote
0 answers

Sequelize : How to do left outer join?

My issue is related to the query, I want to get all the products with it's related category. And a product can have multiple Category My Product table is IdProduct: { primaryKey: true, type: Sequelize.INTEGER, allowNull: false, …
Rupesh
  • 850
  • 2
  • 13
  • 30