Cli: What to use instead of db:seed?

Created on 18 Jan 2016  Â·  15Comments  Â·  Source: sequelize/cli

Recently I was able to run sequelize db:seed to run only seeders which are not in DB. But with new version I get an error:

Unspecified flag "seed". Check the manual for further details.

But the command is still in docs. seed:all works well but it executes all the seeders. Of course I can use --seed option, but it's not useful.

Currently I use seeder to push new data in different DBs and migrations for altering the db structure. Maybe it's not properly? Should I use migrations for new data? Any chance to restore old db:seed behavior?

question

Most helpful comment

Use ´db:seed:all´, it is ´db:seed´ renamed. Now with the seederStorage set
to sequelize, it will save the seeders that ran to the database. If you use
the json file, you can set it to ´json´ and it will save it there.

On Mon, Jan 18, 2016 at 8:41 PM, Andrew Balakirev [email protected]
wrote:

My config:

module.exports = {
development: {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_NAME,
host: process.env.POSTGRES_SERVER,
port: process.env.POSTGRES_PORT,
dialect: 'postgres',
logging: console.log,
seederStorage: "sequelize"
}
};

$ sequelize db:seed

Sequelize [Node: 4.2.1, CLI: 2.3.1, ORM: 3.12.0]

Loaded configuration file "config/migrations.js".
Using environment "development".
Using gulpfile
~/.nvm/versions/node/v4.2.1/lib/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:seed'...
Unspecified flag "seed". Check the manual for further details.

—
Reply to this email directly or view it on GitHub
https://github.com/sequelize/cli/issues/250#issuecomment-172648091.

All 15 comments

Check the readme. If you want to have the old behavior, you need to define the seederStorage option and set it to sequelize on your configuration file.

My config:

module.exports = {
  development: {
    username: process.env.POSTGRES_USER,
    password: process.env.POSTGRES_PASSWORD,
    database: process.env.POSTGRES_NAME,
    host: process.env.POSTGRES_SERVER,
    port: process.env.POSTGRES_PORT,
    dialect: 'postgres',
    logging: console.log,
    seederStorage: "sequelize"
  }
};

$ sequelize db:seed

Sequelize [Node: 4.2.1, CLI: 2.3.1, ORM: 3.12.0]

Loaded configuration file "config/migrations.js".
Using environment "development".
Using gulpfile ~/.nvm/versions/node/v4.2.1/lib/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:seed'...
Unspecified flag "seed". Check the manual for further details.

Use ´db:seed:all´, it is ´db:seed´ renamed. Now with the seederStorage set
to sequelize, it will save the seeders that ran to the database. If you use
the json file, you can set it to ´json´ and it will save it there.

On Mon, Jan 18, 2016 at 8:41 PM, Andrew Balakirev [email protected]
wrote:

My config:

module.exports = {
development: {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_NAME,
host: process.env.POSTGRES_SERVER,
port: process.env.POSTGRES_PORT,
dialect: 'postgres',
logging: console.log,
seederStorage: "sequelize"
}
};

$ sequelize db:seed

Sequelize [Node: 4.2.1, CLI: 2.3.1, ORM: 3.12.0]

Loaded configuration file "config/migrations.js".
Using environment "development".
Using gulpfile
~/.nvm/versions/node/v4.2.1/lib/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:seed'...
Unspecified flag "seed". Check the manual for further details.

—
Reply to this email directly or view it on GitHub
https://github.com/sequelize/cli/issues/250#issuecomment-172648091.

This was an annoying breaking change.

I am assuming this issue is resolved, and I'm closing it.

@Americas Checked - changed config with "seed:all" works fine. Thank you!

But sequelize help still prints outdated info:

...
  db:seed                Run specified seeder.
  db:seed:all            Run every seeder.
  db:seed:undo           Deletes data from the database.
  db:seed:undo:all       Deletes data from the database.

db:seed and db:seed:undo are unavailable in this version of CLI (2.3.1)

Also how to revert only last seeder now?

@Americas interested in this as well

sequelize db:seed:undo --seed seedfile.js removes the selected seed file, you can also add the path to the seedfile for auto-complete help.

The code needs to be changed to allow normal undo's if the storage is not none. But for now, the above code can be used as a work-around.

@Americas OK, thank you clarification.

Maybe reopen this issue for undo's and updating docs?

Any update in this?
when I use "seederStorage": "sequelize" in the config file I expect 'db:seed' to work the same as 'db:migrate', it should run the pending seed files?
and the same for 'db:seed:undo' it should undo the last seed file.
Currently I am using this '--seed seedFile.js' as a workaround.

Gotta say this confused me as well.

I expected db:seed to run all seeders by default. Using db:seed:all (which I can't find documentation for) did the trick.

How to run specify seed?

@TangMonk (and for reference since it's probably a bit late), to run a specific seed you can use:
sequelize db:seed --seed <path to seed file>

How can I apply seeds programmatically?
My use case: Reset a test db, then apply seed data to it, before running tests.

How can I apply seeds programmatically?
My use case: Reset a test db, then apply seed data to it, before running tests.

Did you find any solution for this @noodlebreak?

Was this page helpful?
0 / 5 - 0 ratings