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

TypeError: s.replace is not a function

Env: Postgres: 10.2 Node: 6.11.0 CLI: 2.4.0 ORM: 2.1.3 Model: 'use strict'; module.exports = function(sequelize, DataTypes) { var test = sequelize.define('test', { id: DataTypes.UUID, type: DataTypes.STRING, data:…
nikhil84
  • 3,235
  • 4
  • 22
  • 43
5
votes
1 answer

Sequelize js transaction on destory and bulkCreate not rolling back

I am trying to delete all report_details before bulkCreate/insert the new ones. The problem is when there is an error in bulkCreate it does not rollback. It should bring the destroyed report_details back but it is not working. The way i am testing…
5
votes
1 answer

sequelize.sync({ force: true }) is not working some times

i am using gulp tasks for migration of database. For testing purpose i am using different database. so i need exactly same database. i am trying to do with sequelize.sync({ force: true }) but its not working. i am having my all models in…
5
votes
1 answer

How to easily parse csv file to use in node.js sequelize database migration strategy?

I've got the migration strategy via sequelize-cli set up and running so the table can be constructed properly. It works using sequelize db:migrate and it creates the table just fine. And sequelize db:migrate:undo will delete the table. I've also…
5
votes
1 answer

How to locate the sequelize migration file?

There are a lot of posts on sequelize migration file access through the sequilize-cli file structure. However, if I am not using the sequilize-cli, how does one locate the migration file?
Val
  • 1,260
  • 5
  • 23
  • 39
5
votes
1 answer

Run sequelize model hooks when seeding

I'm currently trying to seed a postgresql database with sequelize, I have hooks declared on my model that work just fine when creating separate records (e.g. tests) Does the data in my seed file need to be as how would show in the final table or can…
Omar Vazquez
  • 407
  • 4
  • 14
5
votes
1 answer

Sequelize CLI Not Finding Env Variables

I am trying to run a db migration with the Sequelize CLI tool, but I'm running into an issue where my ENV variables are not being processed by the tool. In the github repo, it says in version 2.0.0 (I'm on 2.4.0) you can directly access ENV…
cphill
  • 5,596
  • 16
  • 89
  • 182
5
votes
3 answers

nodejs sequelize/cli how to use with node-config

First off it's my first time with Sequelize so be patient. I'd like to use https://github.com/sequelize/cli along with https://github.com/lorenwest/node-config I want sequelize to be able to "compose" it's configuration from multiple source files,…
Whisher
  • 31,320
  • 32
  • 120
  • 201
4
votes
0 answers

Sequelize warning: `resolve/lib/core` is deprecated; please use `is-core-module` directly

While using sequelize-cli "db-migrate": "node_modules/.bin/sequelize db:migrate" i got a warning: `resolve/lib/core` is deprecated; please use `is-core-module` directly Any suggestions how to use properly
4
votes
5 answers

Not able to create ENUM type attribute using sequelize cli

Trying to create a model that has an enum field with certain values using Sequelize CLI. sequelize model:generate --name user --attributes name:string,login_method:enum('email','google') Error: bash: syntax error near unexpected token `(' What is…
r.k
  • 97
  • 1
  • 2
  • 6
4
votes
1 answer

Sequelize migration queryInterface.removeColum fails to work

I created a migration file to add a column as an up and then delete it under down. Here's the migration file code: module.exports = { up: (queryInterface, Sequelize) => queryInterface.addColumn('Books', 'Rating', { allowNull: false, …
Aakash Verma
  • 3,705
  • 5
  • 29
  • 66
4
votes
2 answers

Sequelize-cli how not to include timestamps while generating model and migration files?

Just following the sequelize doc ( http://docs.sequelizejs.com/manual/tutorial/migrations.html ), we can generate a model and a migration file using the sequelize-cli command like: sequelize model:generate --name Users --attributes…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
4
votes
3 answers

How to get model from sequelize.model after use sequelize-cli

I use sequelize-cli to auto generate code for model Student: module.exports = (sequelize, DataTypes) => { var _stu = sequelize.define('stu', { name: DataTypes.STRING, password: DataTypes.STRING, gender: DataTypes.INTEGER, }, { …
吴环宇
  • 337
  • 1
  • 6
  • 13
4
votes
3 answers

typescript error when compiling node module

I downloaded Typescript, Express, Sequelize, Postgres Example and run npm install and npm start. On npm start it is producing some errors. [11:27:11] Starting 'compile:typescript'... ~/node_modules/@types/geojson/index.d.ts(94,54): error TS1005: ','…
artgb
  • 3,177
  • 6
  • 19
  • 36
4
votes
0 answers

Add User ID to Sequelize Audit Fields (createdBy, updatedBy, deletedBy)

What is the best way to adding a User ID as an audit field within Sequelize? I'd like to capture the user ID of anyone who creates, updates, or deletes a record. For example: { tableName: 'user_profile', schema: 'authentication', timestamps:…
Fred Lackey
  • 2,351
  • 21
  • 34