const dotenv = require('dotenv') dotenv.config() const Sequelize = require('sequelize') const path = require('path') const Umzug = require('umzug') const d = new Date(); const datestring = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate() const timestring = d.getHours() + ":" + d.getMinutes(); /** * Creates a basic sqlite database at the path * provided by your .env file */ // MIGRATE TO // const targetDbSequelizeInstance = new Sequelize({ // dialect: 'sqlite', // storage: `./cleaned/${datestring}/${process.env.LOCAL_SQLITE + '_' + timestring + '.sqlite'}` // }) const targetDbSequelizeInstance = new Sequelize( process.env.TARGET_DB, process.env.TARGET_U, process.env.TARGET_PW, { host: process.env.TARGET_HOST, port: process.env.TARGET_PORT, dialect: process.env.TARGET_DIALECT, logging: false } ) // SEED FROM const seedDb = new Sequelize( process.env.SEED_DB, process.env.SEED_U, process.env.SEED_PW, { host: process.env.SEED_HOST, dialect: process.env.SEED_DIALECT, logging: false } ) const migrator = new Umzug({ migrations: { path: path.join(__dirname, './migrations'), params: [ targetDbSequelizeInstance.getQueryInterface() ] }, storage: 'sequelize', storageOptions: { sequelize: targetDbSequelizeInstance } }) ;(async () => { /** * Checks migrations and run them if they are not already applied */ await migrator.up() // Uncomment to destroy things // await migrator.down() console.log('\n***\n\nAll migrations performed successfully!\n' ) })() module.exports = seedDb