Add 'truncate' option to sequelize.sync. #2671
Add 'truncate' option to sequelize.sync. #2671dkushner wants to merge 2 commits intosequelize:masterfrom
Conversation
|
@dkushner how is this exactly related to sync? Wouldn't this simply be a standalone |
|
(and i actually believe we have truncate support via |
lib/sequelize.js
Outdated
|
@mickhansen, it definitely can be a stand-alone truncate method. Would that be preferable? I was trying to avoid disrupting the existing API as much as possible. I also have a number of conceptual objections to the use of sync({ force: true }) given that Sequelize models do not represent an authoritative source for a database schema (and should not). |
|
@dkushner well in my opinion it doesn't just make a lot of sense in I neither fully disagree or agree with your objections to |
|
@mickhansen, I just saw your comment regarding the For example, it would just be something like: return Promise.reduce(this.modelManager.daos, function(ag, dao) {
return dao.delete({}, { truncate: true });
}, null);Perhaps this is contrived, but a way to simply clear all rows of the database without affecting the schema seems useful to me. Thoughts? |
|
@dkushner Utility methods are fine to have. |
|
Needs a rebase @dkushner, didn't see that you moved it to it's own method. |
|
@mickhansen, gotcha. My bad on that. |
|
Ping @dkushner |
|
No response, closing |
Fixes #2670.