Monorepo containing core modules of Zeichen.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

migrate.ts 774 B

12345678910111213141516171819202122232425
  1. import models from './src/models'
  2. import seeds from './src/seeds'
  3. // TODO support NoSQL
  4. export const up = async queryInterface => {
  5. const createTablePromises = models.map(m => queryInterface.createTable(m.tableName, m.attributes))
  6. await Promise.all(createTablePromises)
  7. const seedTablePromise = models
  8. .filter(m => Boolean(seeds[m.modelName]))
  9. .map(m => {
  10. console.log(JSON.stringify(seeds[m.modelName]))
  11. return queryInterface.bulkInsert(m.tableName, seeds[m.tableName])
  12. })
  13. return Promise.all(seedTablePromise)
  14. }
  15. export const down = async queryInterface => {
  16. const dropTablePromises = models
  17. .reduce((reverse, m) => [m, ...reverse], [])
  18. .map(m => queryInterface.dropTable(m.tableName))
  19. return Promise.all(dropTablePromises)
  20. }