I am able to form your "Sql-Based Database" connected to "Sequelize" to look like "Sequelize Models" in your "Sequelize Model Schemes"
Migration is the process of moving from one to anotherForm ofDatabaseSinceMigration is version-based process and is reversible, our auto-migration system doesn't generate a single version file and do the changing and adding automatically. so you can't call it a migration it self but auto-migration.
Caution : It's still in Beta phase so don't expect a very clean output although it won't delete or overwrite on your dataYet. But in the next updates we will add some features that includes doing this.Although it will come with granting your permission byOptions parameter.
Suppose you have a object of "Sequelize" :
constoptions={host :host,port :port,dialect:'mysql',define :{charset:'utf8',collate:'utf8_general_ci',}};constsequelize=newSequelize(tableName,userName,password,options);Add "INFORMATION_SCHEMA" Database as a "Sequelize" Object Beside it ( in current runned "SQL-Based Database System" instance ) like below:
constoptions={host :host,port :port,dialect:'mysql',define :{charset:'utf8',collate:'utf8_general_ci',}};constsequelize=newSequelize(tableName,userName,password,options);constsequelizeInfo=newSequelize('INFORMATION_SCHEMA',userName,password,options);And then add "sequelize-true-migration" package and Create new Object with "new" and call "synchronize" method for Syncing model with database:
constSequelizeTrueMigration=require('sequelize-true-migration');conststmObj=newSequelizeTrueMigration(name,sequelize,sequelizeInfo,database,{forceTruncate:false})stmObj.synchronize();Caution : For getting affected restart your project. probably like this :
- Nodemon : On saving files
- PM2 :
pm2 restart %Name-Of-Your-Project%
Ctrl+c ( On running project ) node %Main-Project-File%.js
And Done. No need to Do Anything.