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

Custom query on sequelize seeder

Any one know how to custom select query on sequelize seeder I have tried two ways, but no one work First attempt up: function(queryInterface, Sequelize) { return queryInterface.sequelize.query( 'SELECT * FROM "Users" WHERE username =…
Toan Tran
  • 1,937
  • 1
  • 24
  • 37
7
votes
2 answers

How/Where to run sequelize migrations in a serverless project?

I am trying to use Sequelize js with Serverless, coming from traditional server background, I am confused where/how to run database migrations. Should I create a dedicated function for running migration or is there any other way of running…
7
votes
3 answers

Sequelize-CLI Seeders - Cannot read property of undefined

I have been struggling with the db:seed:all for over an hour now and slowly I am losing my mind about this. I have a simple model: 'use strict'; module.exports = function (sequelize, DataTypes) { var Car = sequelize.define('Cars', { name:…
Tikkes
  • 4,599
  • 4
  • 36
  • 62
6
votes
2 answers

Sequelize migrations - add foreign key constraint issue

I need to remove the existing foreign key constraint on a column and add a new constraint with same name which refers to primary key of another table. I am getting an error ERROR: Constraint type must be specified through options.type. Though I am…
6
votes
2 answers

How to get all records from the last 7 days sequelize

I am trying to get all records from a mysql Database with sequelize and I have tried following approaches: shops.findAndCountAll({ where: { createdAt: { [Op.gte]: moment().subtract(7, 'days').toDate() } } }) and when I use this, I…
nad34
  • 343
  • 4
  • 13
6
votes
1 answer

sequelize Unknown column '' in 'on clause'

I have the below code and I am having a problem. I'm trying to include the images table... There is a relation between the order and images already, but I don't know why it's showing the error below: Unhandled rejection SequelizeDatabaseError:…
Faisal
  • 441
  • 1
  • 7
  • 18
6
votes
2 answers

Ignore container exit when using docker-compose

I am setting up a test infrastructure using docker-compose. I want to use the docker-compose option --exit-code-from to return the exit code from the container that is running tests. However, I also have a container that runs migrations on my…
Max Paymar
  • 588
  • 1
  • 7
  • 23
6
votes
3 answers

Sequelize createdAt and updatedAt timestamps are wrong

I created a table with timestamps using sequelize. when I am updating the table, it automatically updates the timestamp (i.e createdAt and updatedAt). but these times are different from my local time. I have attached herewith 2 screenshots with the…
Roledenez
  • 751
  • 4
  • 16
  • 43
6
votes
1 answer

Sequelize.INTEGER vs DataTypes.INTEGER

In code from 2016 using sequelize ORM, I see model types defined with this pattern: module.exports = function(sequelize, DataTypes) { const Tasks = sequelize.define("Tasks", { id: { type: DataTypes.INTEGER, [ ...etc.] However…
musicformellons
  • 12,283
  • 4
  • 51
  • 86
5
votes
4 answers

Cannot find module 'sequelize/types'

anyone knows why i am getting this error this is my code "use strict"; const { DataTypes } = require("sequelize/types"); module.exports = { up: async (queryInterface, DataTypes) => { await queryInterface.createTable("dummytables", { id:…
Aakash
  • 139
  • 1
  • 3
  • 22
5
votes
2 answers

How to associate models in ES6 syntax using sequelize v6

I am using sequelize ORM 6.4.0 and CLI 6.2.0 in an express/nuxt web app. (Also: Node 14.15.3, npm 6.14.11). Background: Goal is to make a web app for creating mariokart tournaments and track data about individual racers performance on different…
5
votes
1 answer

Sequelize Raw query not returning array for has many

I am trying to use a raw sql query in sequelize and have this code. My table structure is an external_profile that has many connections. const users = await models.sequelize.query("SELECT `External_Profile`.*, AVG(Connections.rating) AS rating,…
5
votes
1 answer

Sequelize addColumn migration always referring public schema

I have an Express application with Sequelize as ORM and PostgreSQL as database. Database is setup in such a manner where every tenants in my application will have different schemas.The migration files which exists in my application contains…
5
votes
1 answer

ERROR: Attribute '' cannot be parsed: Cannot read property 'dataType' of undefined

I was creating document_types table using following cli command sequelize model:create --name User --attributes name:string, username:string, email:string, password:string
Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73
5
votes
1 answer

Error seeding JSON data with sequelize into PostgreSQL database

Occurs when I run the sequelize-cli command sequelize db:seed:all When I try and seed an object as JSON I get the following error: ERROR: Invalid value { viewId: null, dateRanges: [ { startDate: null, endDate: null } ], samplingLevel:…
Jaygles
  • 93
  • 1
  • 8
1 2
3
33 34