在我保持 {force:true} 的同时,我遇到了 sequelize 的一些问题.在这种情况下,旧数据将被删除,新数据库将被创建,而我保存的数据将丢失.我想用旧值创建新数据库.使用node.js中的 sequelize 可以做到这一点
解决方案当您的数据库中有一些数据并且想要在db中进行某些更改时,您有两种可能性:
迁移使您可以不丢失数据并指示后续如何更改表.
此处
I am facing some problem with sequelize while i keep {force: true} . In this case old data dropped and new database is created and my saved data get lost. I want to create new database with old values. Can that possible with sequelize in node.js
解决方案When you have database with some data and want to make some changes in db you have two possibilities:
Migrations allow you to to don't loose your data and instruct sequelize how to change tables.
There is ticket for recreating tables with alter tables instead of drop tables here
更多推荐
如何在node.js中使用sequelize从旧数据库重新创建数据库
发布评论