Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to seed a one file only with sequelize-cli?

sequqlize-cli db:seed:all is working fine, but how to seed only one file? Tried to db:seed:[name-that-i-gave-with-create-command] and db:seed:[full-path-to-seed-file.js] but it doesnt work. It outputs nothing. Docs say sequelize db:seed Run specified seeder But how to do that?

like image 879
tzi0 Avatar asked Nov 23 '20 13:11

tzi0


People also ask

How do I seed a specific file in Sequelize?

It has a useful command called seed:create , which will generate 2 files for you: a seed . Running this command will result in a file in your seeders directory with code that looks like this: 'use strict'; module. exports = { up: function (queryInterface, Sequelize) { /* Add altering commands here.


2 Answers

To run a specific seed indicate --seed <seed_file_nams.js>:

sequelize db:seed --seed my_seeder_file.js
like image 171
Anatoly Avatar answered Oct 04 '22 05:10

Anatoly


We can launch a specific seeder via npx sequelize-cli with the following command :

npx sequelize-cli db:seed --seed my-seeder-file.js
like image 27
NSA Avatar answered Oct 04 '22 05:10

NSA