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
12
votes
6 answers

My models for DB using Sequelize don't doing migration

I've two models: user.js 'use strict' module.exports = function(sequelize, DataTypes) { var User = sequelize.define('User', { gid: { type: DataTypes.INTEGER, allowNull: false, primaryKey: true, autoIncrement:…
11
votes
4 answers

How to clone/copy instance item/row in sequelize

I tried to find a way to copy/clone instances in Sequelize but without success. Is there any way to do it with a built-in function or without? What I want is to simply copy rows in the database and the new item should have only a different id.
agims7
  • 216
  • 2
  • 6
  • 16
11
votes
3 answers

find records in sequelize seeds

I've been trying to write some seeds for my project, but I've ran into a bit of a snag. I've got a many-to-many relation with my users and roles table. So, when I'm seeding the database I need to add a record with correct ids into my join table. In…
radical_edo
  • 934
  • 2
  • 11
  • 29
10
votes
2 answers

Sequelize CLI : cannot read property 'replace' of undefined when migrating DB

I am trying to migrate DB using db:migrate function, however I am getting the error printed: ERROR: Cannot read property 'replace' of undefined I have referred to other solutions for this error on GitHub but none resolve the issue. I am using…
9
votes
4 answers

How to delete a migration using sequalize-cli

I manually deleted a migration file name 20171125081136-create-task.js. After deleting the migration file, I ran this command db:migrate:undo:all While running this command I'm getting an error in the terminal: ERROR: Unable to find migration:…
Rahul Dagli
  • 4,301
  • 15
  • 47
  • 85
9
votes
2 answers

Sequelize-cli how to create seed files from an existing database?

Issue: In order to start in a clean environment for developing stuff for a web app I would appreciate to be able to retrieve some data from an existing DB (let say the 10 first lines of every tables) in order to create a sequelize seed file per…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
9
votes
1 answer

Executing Multiple Sequelize JS model query methods with Promises - Node

I am having a problem retrieving data from database using sequelize js. I am new to NODEJS. I don't know if Promise and Promise.all are built in functions So i install and require npm promise in my code too. Below is my code. var Promise =…
Syed Danial
  • 635
  • 1
  • 6
  • 16
9
votes
2 answers

Sequelize in Node/Express - 'no such table: main.User` error

I'm trying to build a simple Node/Express app with Sequelize, but when I try to create a new record in my relational database, I am getting the error Unhandled rejection SequelizeDatabaseError: SQLITE_ERROR: no such table: main.User. Basically, I…
skwidbreth
  • 7,888
  • 11
  • 58
  • 105
8
votes
3 answers

Getting Error: Unknown authenticationOk message typeMessage { name: 'authenticationOk', length: 23 }

I have installed Postgres 13 in windows 10. Configured all the right credentials in the environment file of the project. The project uses the below dependencies and it was created in ubuntu. "pg": "^7.4.3", "pg-hstore": "^2.3.2", "sequelize":…
HV Sharma
  • 4,891
  • 3
  • 15
  • 30
8
votes
1 answer

Sequelize Seeding ARRAY(ENUM)

I cannot seem to figure out how to seed ARRAY(ENUM) using Sequelize. When I am registering a user via my app, I can create a new user fine, but when I am using the queryInterface.bulkInsert in a seed file, I am getting: ERROR: column "roles" is of…
8
votes
6 answers

How to return only specific attributes when using Sequelize Create method

I have been searching through Sequelize documentation and forums for the correct syntax and it seems I am doing it the right way, but for some reason the password field is still being returned in the response payload... The following link shows the…
James
  • 429
  • 1
  • 8
  • 17
8
votes
3 answers

Sequelize Migration: relation does not exist
I'm working through an Author hasMany Books example and am attempting to run a sequelize-cli migration, but am getting the following issue when I run the following migration: ERROR: relation "authors" does not exist This is the first migration to…
MunkiPhD
  • 3,636
  • 1
  • 29
  • 51
7
votes
2 answers

Defining Sequelize on google cloud sql nodejs

Hi i having an issue connecting to Google Cloud SQL from GAE. My app is running inside docker container here is the docker file FROM node:8.10.0-alpine ARG NODE_ENV=production ENV NODE_ENV=$NODE_ENV # env like sql user db instance connection…
7
votes
4 answers

How to run Sequelize down migration for single file

I'm working on a migration using Sequelize. If the migration up method throws an error, the migration is not logged in the database as having completed. So, if I run db:migrate:undo, it instead runs down on the previous (and working) migration. As a…
Matt Molnar
  • 2,412
  • 3
  • 22
  • 28
7
votes
1 answer

How to insert a row with association through sequelize queryInterface

I am using sequelize cli with sequelize to generate a seeder file for a many to many join table Here I have Users and Collections and User_Collections as the join table I have already created seeder files for Users and Collections but I want to…
Rahul Ravindran
  • 318
  • 3
  • 11
1
2
3
33 34