How to recreate database from old database using sequelize in node.js

限于喜欢 提交于 2019-12-12 13:19:47

问题


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


回答1:


When you have database with some data and want to make some changes in db you have two possibilities:

  1. as you said recreate db, but this will drop tables (erase your data).
  2. use migrations (you can read about it here)

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



来源:https://stackoverflow.com/questions/35428355/how-to-recreate-database-from-old-database-using-sequelize-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!