sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 526 forks source link

db:seed:undo not working #564

Closed OscarHYCheung closed 4 years ago

OscarHYCheung commented 7 years ago

Hi there, according to the documentation in http://docs.sequelizejs.com/manual/tutorial/migrations.html#undoing-seeds, I should be able to undo the most recent seed with db:seed:undo. However, after running node_modules/.bin/sequelize db:seed:undo, the data created by the latest seed are still in the DB.

And if I run node_modules/.bin/sequelize db:seed:undo:all, it is working fine to undo all seeds.

I'm not sure is that related to the warning CLI v3 is not fully compatible to Sequelize v4.

Thanks.

refs sequelize/sequelize#8421

What are you doing?

I would like to undo the last data seed with

node_modules/.bin/sequelize db:seed:undo

What do you expect to happen?

The latest seed should be reverted

What is actually happening?

No data removed, and got the follow output:

Sequelize CLI [Node: 6.11.1, CLI: 3.0.0, ORM: 4.13.2]

WARNING: This version of Sequelize CLI is not fully compatible with Sequelize v4. https://github.com/sequelize/cli#sequelize-support

Loaded configuration file "config/database.json".
Using environment "development".
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:236:13

Dialect: postgres Dialect version: pg: 7.3.0, pg-hstore: 2.3.2 Database version: PostgreSQL 9.6.5 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit Sequelize version: 4.13.2 Sequelize CLI version: 3.0.0

sushantdhiman commented 7 years ago

I think if no argument is passed to this command then it should undo the seed to match with migrate:undo

sushantdhiman commented 7 years ago

Need to change its description hence docs tag

Taylor123 commented 6 years ago

Docs seem to still be outdated. --help in the cli does not say how to flag the seed file to undo.

What's the proper way to do so? Thanks!

cyrilchapon commented 6 years ago

@Taylor123

sequelize db:seed:undo --seed '[seedName]'

(without .js and the path, just like in the storage)

Be careful, you can "undo" multiple times the seed (it doesn't check the storage)

+1, it needs to match migration stuff. EDIT: and to be documented

cyrilchapon commented 5 years ago

Status of this ?

antonioGodinez commented 5 years ago

@Taylor123

sequelize db:seed:undo --seed '[seedName]'

(without .js and the path, just like in the storage)

Be careful, you can "undo" multiple times the seed (it doesn't check the storage)

+1, it needs to match migration stuff. EDIT: and to be documented

Thanks, we have been struggling with this for several hours and could not find anything in docs. This worked for us.

BartusZak commented 4 years ago

sequelize db:seed:undo is still not reverting last seed for me :(

Is there a way to merge @empeje PR ?

sushantdhiman commented 4 years ago

Fixed by https://github.com/sequelize/cli/pull/908