import models from './src/models' import seeds from './src/seeds' // TODO support NoSQL export const up = async queryInterface => { const createTablePromises = models.map(m => queryInterface.createTable(m.tableName, m.attributes)) await Promise.all(createTablePromises) const seedTablePromise = models .filter(m => Boolean(seeds[m.modelName])) .map(m => { console.log(JSON.stringify(seeds[m.modelName])) return queryInterface.bulkInsert(m.tableName, seeds[m.tableName]) }) return Promise.all(seedTablePromise) } export const down = async queryInterface => { const dropTablePromises = models .reduce((reverse, m) => [m, ...reverse], []) .map(m => queryInterface.dropTable(m.tableName)) return Promise.all(dropTablePromises) }