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

Query Postgres Nested JSONB column using sequelize

Hi I have a table where I use JSONB to store Nested JSON data and need to query this JSONB column Below is the structure of the table { "id": "5810f6b3-fefb-4eb1-befc-7df11a24d997", "entity": "LocationTypes", …
naveen
  • 107
  • 1
  • 1
  • 10
2
votes
1 answer

How to catch Sequelize Migration Errors and prevent adding migration to the SequelizeMeta table

I've recently started to experiment with Sequelize Migrations using sequelize-cli. I noticed that if the migration script throws an error (using a try-catch block), sequelize-cli still updates the SequelizeMeta table with the migration as if it was…
Tony Guinta
  • 633
  • 1
  • 8
  • 14
2
votes
1 answer

Sequelize migration tool can not find schema defined in config.json

When start a docker container from postgres image, it only creates a public schema under a database. here is my setting postgres: container_name: postgres image: postgres:latest ports: - "${DB_PORT}:5432" …
eded
  • 3,778
  • 8
  • 28
  • 42
2
votes
3 answers

Connect to postgres RDS from ec2 using Sequelize

I created an ec2 instance, in default VPC, and configured my node.js project as I do on my local machine. I created RDS postgres instance in the default VPC and permitted all the traffic. After this I tried to run migrations from ec2 with "npx…
2
votes
0 answers

How can I set database failover portal with Sequelize?

I am using sequelize to connect to a postgres db which is hosted on compose.io. const db = new Sequelize(DATABASE_URL, { logging: false, pool: { max: 15, min: 1, idle: 10000, acquire: 10000, }, }); How can I set a failover…
perrosnk
  • 835
  • 2
  • 13
  • 23
2
votes
1 answer

sequelize nested include result set parent object

I have multiple includes in single query of sequelize but I can't get the result as I want. please refer below code const users = await User.findAll({ include: { model: Tool, as: 'Instruments', include: { model: Teacher, …
chirag sorathiya
  • 1,223
  • 8
  • 29
2
votes
2 answers

Automatically get all table columns in a sequelize model

I am learning sequelize js and I was wondering if there is a way to define a Model and have it get all the table columns automatically ? We have a huge dataset and the table that I will base the Model on, has 200 columns. Even if I need only 50…
codebot
  • 517
  • 8
  • 29
  • 55
2
votes
1 answer

Sequelize Include Model But Without Tablename

I'm newbie for Sequelize I have a problem with "Nested Eager Loading" I have 2 Table with 1-to-many relationship Comment Table User Table I use this code for the query Comment.findAll({ include: [User] }) I got { id: 1, comment:…
Sunny
  • 167
  • 1
  • 3
  • 13
2
votes
1 answer

Sequelize "model.associate" property doesn't work anymore?

I'm using sequelize v5.21 and sequelize-cli v5.5.1 for a MySQL database. I'm currently trying to create some association 1:M under the following model generated code from the cli like so: Where: a is the source and b the target. model.associate =…
2
votes
0 answers

Cant make Associations sequelize

Im trying to create association between two tables using models that are generated by sequelize-cli. But it is not making the relations in db. Model User User.hasMany(models.Albums, { foreignKey: 'user_id', as: 'userAlbums' }); …
2
votes
1 answer

How to display SQL executed in sequelize-cli migration, for later use in production update

Question on sequelize-cli running db:migrate to create/alter tables on MySQL. Running migration as per the document. I was seeing the sql (raw query) as part of the console output from sequelize-cli as shown below: npx sequelize-cli db:migrate…
nbs
  • 311
  • 1
  • 12
2
votes
0 answers

how can I update existing data using upsert sequelize cli

I want to update some data using migrations, I have a table with this info: id userName 1 User1 2 User2 3 User3 4 User4 Following the…
R.Romero
  • 161
  • 1
  • 4
  • 15
2
votes
1 answer

Sequelize migration - defining an empty JSON array

In my MySQL database i have a JSON column that i created using the following sequelize-cli migration: queryInterface.addColumn( 'Users', 'favorites', { type: Sequelize.JSON, allowNull:…
Gambit2007
  • 3,260
  • 13
  • 46
  • 86
2
votes
2 answers

sequelize db:migrate hanging

I am trying to get my models to migrate to the postgress db I am using, which is hosted locally and I confirmed is up and running fine. When I run sequelize db:migrate it says Loaded configuration file "config\config.json" Using environment…
nukeLEAR
  • 25
  • 7
2
votes
1 answer

Starting a new Sequelize backend and cannot connect to SQLite DB

I have the most basic bones of a new app.js set up with sequelize and express in node. Whenever I run the project I get: { Error: SQLITE_CANTOPEN: unable to open database file errno: 14, code: 'SQLITE_CANTOPEN' } I've searched around for solutions,…
wiljago
  • 147
  • 3
  • 14