New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'truncate' option to sequelize.sync. #2671
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 |
* @param {Boolean} [options.truncate=false] Similar to force, if truncate is | ||
* true, each DAO will do TRUNCATE TABLE, eliminating all rows within the | ||
* table while maintaining the table structure. Note that force will always | ||
* override this option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janmeier will this doc syntax work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janmeier Adding some more commits to move the functionality out of sync()
. What about the syntax breaks the docs? I'll make sure not to do it again.
@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.