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 model creation

I've been trying to create a user model using sequelize cli but whenever I insert more parameters like primary key and unique the parser fails. Eg: npx sequelize model:create --name user --attributes "name:{dataType:string, primaryKey:true},…
2
votes
2 answers

How to create database table from sequelizejs model definition?

There are several models defined with sequelizejs for my nodejs project. Here is an example of Event model in event.js: const Event = db.define('event', { id: {type: Sql.INTEGER, primaryKey:true, min: 1}, name: {type:…
user938363
  • 9,990
  • 38
  • 137
  • 303
2
votes
1 answer

How to modify sequelize migrations

when i change my model and migration file and run sequelize db:migrate:undo and then sequelize db:migrate, changes wont be made on the database table. Instead, the changes affect the last migration file / model file.
Ifeora-emeka
  • 77
  • 2
  • 10
2
votes
1 answer

Join or Populate Query In Sequelize

Initially i was using mongoDb to access or manipulate database. But now I want to shift to mySQL but then I used Sequelize ORM to get or set data. But I am having problem in joining or populating 2 tables together to show the data on screen I have…
Aayushi Gupta
  • 369
  • 4
  • 18
2
votes
3 answers

Issues when migrating with association under MS SQL

I have issues, when running: sequelize db:migrate under MS SQL. I have a contact model that belongsTo 2 other models. So I added this to the contact.associate = function(models)…
Jan Krüger
  • 83
  • 1
  • 10
2
votes
2 answers

Sequelize: Adding a day to the date doesn't work

I have a column updatedAt in my table User which is of Date type, it stores date along with time. I want to query using only date and not datetime. I am using sequelize Sequelize.Op.gt and Sequelize.Op.lt operators to get Users updated on that exact…
niaS
  • 323
  • 4
  • 18
2
votes
1 answer

Sequelize - query with join table

I'm building role based authentication with permissions. I have following tables: Users, Groups, GroupPermissions and Permissions. Users model: module.exports = (sequelize, DataTypes) => { var User = sequelize.define('User', { id: { …
Freshman
  • 25
  • 2
  • 4
2
votes
1 answer

node server not returning any response after API request

I am building an API with Node.js, Express, MYSQL and with the help of sequelize. I am using MVC pattern. The problem I am encountering however is the server cannot send back any http response after request. When sending a post request for example…
wafutech
  • 481
  • 10
  • 30
2
votes
2 answers

Sequelize with sqlite3 doesn't create a database

Could you please help me to solve the problem? I use sqlite3 with sequelize npm package. After running migrations I don't see errors in console but I also don't see any database file. Also I can run migrations again and again, it doesn't look like…
lutaev
  • 298
  • 1
  • 4
  • 20
2
votes
1 answer

Sequelize Migration server connect with two databases

I have created a sequalize migration server and connected with a mysql database using Sequelize CLI by referring this doc. Now i want to know, is it possible to run migrations on another mysql database using the same migration server or do i need to…
Ramitha Rupasinghe
  • 203
  • 1
  • 4
  • 12
2
votes
1 answer

Sequelize migration recreate table

I want to totally recreate two tables (they will change significantly). The id will change so it's probably difficult to recreate those data. Will they recreate themself from models if I just drop those tables in migration file?
speedingdeer
  • 1,236
  • 2
  • 16
  • 26
2
votes
4 answers

List applied sequelize migrations

Is there a way to show the migrations already applied ? I would like to know which migration is the last one, so I can decide whether to undo it or not.
FlyingPumba
  • 1,015
  • 2
  • 15
  • 37
2
votes
1 answer

where can i specify the compiled migration

I'm using postgres database ORM sequelize and I'm using typescript as a backend script for in express nodeJs. First question: Is there a way to create a model directly to.ts ? Second question: While trying to migrate the db I'm getting this…
2
votes
1 answer

How to add new attributes to schema after the migration?

currently I am working on a node.js project, and I found a problem while I was building the schema, usually, I use command line provided by http://docs.sequelizejs.com/manual/tutorial/migrations.html to define my schema, which is $…
starsneverfall
  • 137
  • 1
  • 2
  • 15
2
votes
0 answers

Sequelize migrations - Unable to change reference on column

My database is MSSQL. I have a migration script where I have created the table like this: module.exports = { up: function(queryInterface) { return queryInterface.createTable( 'tablename', { 'column1': { …
callmekatootie
  • 10,989
  • 15
  • 69
  • 104