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

SET FOREIGN_KEY_CHECKS = 0 not working in Sequelize migration

Here is my function: up: queryInterface => { return queryInterface.sequelize.query('SET FOREIGN_KEY_CHECKS = 0') .then(() => queryInterface.dropTable('my_table')); }, This query works in the table: SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF…
Nikronis
  • 141
  • 2
  • 11
3
votes
1 answer

Sequelize db:migrate doesn't update model

I made a table using sequelize-cli, however I forgot to add a column: title. So I generated new migration: $ sequelize migration:create --name update-notes And put these codes inside of migration file: 'use strict'; module.exports = { up:…
modernator
  • 4,341
  • 12
  • 47
  • 76
3
votes
3 answers

Sequelize. ERROR: null value in column "createdAt" violates not-null constraint

I'm following the tutorial here: http://docs.sequelizejs.com/manual/tutorial/migrations.html#creating-first-model-and-migration- But when I do: node_modules/.bin/sequelize db:seed:all it gives to me: ERROR: null value in column "createdAt" violates…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
3
votes
1 answer

How to merge Included Model Attributes on Sequelize Query

Does anyone know how to perform a query in Sequelize where (no SQL pun intended) included model attributes are merged onto the parent model? The user model, user_profile model, and query are below. I'd like to return a single object with the…
lgants
  • 3,665
  • 3
  • 22
  • 33
3
votes
3 answers

Sequelize : One-to-Many relationship not working when inserting values

I got a One-to-Many relationship between two objects : Dashboard, and Chart, described like this : module.exports = function (sequelize, DataTypes) { const Dashboard = sequelize.define('Dashboard', { id: { type: DataTypes.INTEGER, …
Térence
  • 61
  • 2
  • 5
3
votes
0 answers

Sequelize-cli how to generate a migration file from an existing model?

Issue: In order to start in a clean environment for developing stuff for a web app I would appreciate to be able to duplicate (clone) an existing DB structure into both a sequelize model + migation files and then seed this with dumb data. I have…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
3
votes
2 answers

Sequelize + sequelize cli seeding bulk amount of random data

What is the best way, or any way really to insert data for two separate tables and a join table in node/sequelize cli i.e. i have a addresses table, I add in this const faker = require('faker'); const models =…
Karan
  • 1,141
  • 2
  • 19
  • 42
3
votes
2 answers

Sequelize - How do I seed database with Geometry value?

I use Sequelize to connect to my PostgreSQL database and during development, I use seed files to populate database with example data. I recently installed PostGIS for my database and wanted to use the GEOMETRY('POINT') type to describe the…
3
votes
1 answer

Seed data in Sequelize with Many-to-Many Relationship

I have messed around with trying to get some default data for my application to seed into my PostgreSQL database using sequelize. So far I have only found one way to do it, and it's not ideal. My main question is if anyone here knows the "best…
joshrathke
  • 7,564
  • 7
  • 23
  • 38
3
votes
0 answers

Execute Many to Many migration using sequelize

this is my first time using sequelize and I want to run a many to many migration. This is the setup of my models: models/collection.js 'use strict'; module.exports = function(sequelize, DataTypes) { var Collection = sequelize.define('Collection',…
3
votes
1 answer

Sequelize.js still deletes table row even if paranoid is set to true

I'm having trouble getting Sequelize.js to soft delete the rows in my table. I used Sequelize cli to do all my migrations and I'm not using the sync feature to resync the database on start. I have the timestamp fields and even the deletedAt field in…
bach942
  • 77
  • 1
  • 9
3
votes
1 answer

Sequelize: connect to database on run time based on the request

I am working on a node.js app where I need to connect to more than one databases. One of the database is central database which contains information common to all. And then there are country level databases where data is stored according to the…
Jitender Singla
  • 133
  • 1
  • 12
3
votes
1 answer

What's the "correct" way to bootstrap a Sequelize schema?

When getting started with sequelize, I simply used force:true to keep the database working for development, but now that I'm transitioning to test/production this is obviously no longer a good choice. I've defined my schema in my code like…
Julian
  • 424
  • 2
  • 8
3
votes
1 answer

Promise chaining in Sequelize migrations - relation does not exist

This simple test code: return queryInterface.createTable('tadam', {id: Sequelize.INTEGER, humus: Sequelize.STRING(255)}) .then(queryInterface.sequelize.query('ALTER TABLE tadam ADD PRIMARY KEY (id)')); returns the following error: Unhandled…
Milkncookiez
  • 6,817
  • 10
  • 57
  • 96
2
votes
1 answer

.sequelizerc with ESM modules doesn't work with @babel/register and @babel/preset-env

If I change in .sequelizerc file babel packages to @babel/register and @babel/preset-env sequelize CLI stops working (the following code works as is). require("babel-register")({ presets: [["babel-preset-env", { targets: { node: "current" }…
digitalniweb
  • 838
  • 1
  • 7
  • 15