3
1

seed.ts 697 B

1234567891011121314151617181920212223242526272829303132333435
  1. import db from './db'
  2. import {
  3. Block,
  4. Category,
  5. Channel,
  6. Council,
  7. Member,
  8. Post,
  9. Proposal,
  10. Thread,
  11. } from './models'
  12. const blocks :any[]= [] //require('../../blocks.json')
  13. async function runSeed() {
  14. await db.sync({ force: true })
  15. console.log('db synced!')
  16. console.log('seeding...')
  17. try {
  18. if (blocks.length) {
  19. console.log('importing blocks')
  20. const b = await Block.bulkCreate(blocks)
  21. console.log(`${b.length} blocks imported`)
  22. }
  23. } catch (err) {
  24. console.error(`sequelize error:`, err)
  25. process.exitCode = 1
  26. } finally {
  27. console.log('closing db connection')
  28. await db.close()
  29. console.log('db connection closed')
  30. }
  31. }
  32. runSeed()