Zeichen's app for both server and client.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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. }