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

Sequelize error : cannot find property "startYear" of undefined

I am using sequelize cli and got each migration file for each model generated, I am trying to generate all the tables with a single migration file as they are dependent on each other, but I am keep getting this error cannot find property startYear…
Drupad Singh
  • 48
  • 1
  • 4
0
votes
2 answers

Node sequelize throwing undefined error when checking if an object exists

Ok, so this is either very weird or I'm not understanding something that is happening. I am trying to load the sequelize library in node. when trying to connect I'm using the CLI generated index.js file however this line: if…
user4747724
0
votes
1 answer

Node Sequelize: Prevent table generation on startup

As I'm new to sequelize, and I have the following question: When I start my application, it automatically creates tables based on my model definitions, is there a way to prevent this from happening? I want to use my migration script to create the…
KevinC
  • 115
  • 1
  • 1
  • 8
0
votes
1 answer

Making change in database model - Sequelize

I'm a beginner and I'm using Sequelize for my database. I created the model, did a migration after creating it, then added mocks & seeds but realized that I made a mistake for two attributes' data types. I need to change that but I'm not sure what…
Kathy
  • 97
  • 1
  • 4
  • 12
0
votes
1 answer

How to update table with sequelize

For example, I have db with table Users, which have some fields: (id, username). Some later I decided add new field - email. Of course, I update model, migration and run sequelize db:migration. But nothing happened. Any ideas how to add it in Users?
Marat Kruglov
  • 21
  • 1
  • 1
0
votes
0 answers

How do you persist an instance that requires user input

I know there's tons of material on sequelize, but my question is very specific and I can't seem to find the answer anywhere. I'm trying to save the inputs of users for my full stack app, onto my database, using the mvc setup const restaurants =…
0
votes
1 answer

Sequelize cli migration with association reference causes error `ERROR: Cannot add foreign key constraint`

Trying to create a very simple proof-of-concept to create table associations with migrations, but cannot add a foreign key when running through the cli - ./node_modules/.bin/sequelize db:migrate Made sure to clear out my SequelizeMeta &…
snn
  • 405
  • 5
  • 15
0
votes
1 answer

confused of nodejs express .env / config file settings

I have 2 questions, and I am asking two questions together since it is related to each other. I am using sequelize-cli for migration, (I used sync({force: true}) before) when I use the command sequelize init the config/config.json is created, and…
jwkoo
  • 2,393
  • 5
  • 22
  • 35
0
votes
0 answers

SequelizeUniqueConstraintError when using models with sequelize seeders

I'm seeding a table using a model like so module.exports = { up: async function (queryInterface, Sequelize) { const company = await Company.create({ name }); Works fine in staging but in production there is an error 20170727141749-admins:…
1192805
  • 988
  • 2
  • 10
  • 26
0
votes
0 answers

Aren't migrations supposed to be not deleted?

I'm using Sequelize for my PostgreSQL in a node app. Let me elaborate my question. I had two migrations - one that created a table and the other that added a column to it. I can see those migration entries in the SequelizeMeta table in my psql but…
0
votes
0 answers

sequalize - find user in array of string

I have user: { name: 'Patrick', ... } I have an array like: ['Patrick, 'James'] I want to find all users depending on my array. I ended up with something like this: models.User.findAll({ where: { name: { $in: names } …
0
votes
6 answers

Connect to local SQL Server with Sequelize

I recently set up a Local SQL Server Db for development of my node app. I'm having trouble trying to connect to it from my node app. I was able to connect with sqlcmd using the command: sqlcmd -S \ I'm using the Sequelize…
C-RAD
  • 1,052
  • 9
  • 18
0
votes
1 answer

How to drop a non-key column without deleting related records with Sequelize Migrations?

I am currently about to learn how to use Sequelize migrations. Therefore I created some example models and migrated them as well. No I tried to delete a column - the migration works fine for that as long as I had no data inserted. So here are my…
Kinaeh
  • 277
  • 6
  • 16
0
votes
1 answer

Raw query in express.js route using sequelize

I am very new to using sequelize. I am running a node.js project created using sequelize cli and trying to run a raw query as below within a "put" express route of my application but keep getting and error: Sequelize.query is not a function The…
Sunny Gohil
  • 319
  • 1
  • 11
0
votes
1 answer

Sequelize 4 - belongs-To-Many insert issue on eagger loading

Hi Folks, I have these two models: const media = sequelize.define('media', { id: { type: Sequelize.UUID, primaryKey: true, defaultValue: Sequelize.UUIDV4 }, name: { type: Sequelize.STRING, allowNull: false,…
Lucas Assmann
  • 41
  • 1
  • 8