简体   繁体   中英

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

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:

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM