text: 'use strict'
  
  const { seedDB, db, models: { User } } = require('../server/db')
  
  /**
   * seed - this function clears the database, updates tables to
   *      match the models, and populates the database.
   */
  
  
  /*
   We've separated the `seed` function from the `runSeed` function.
   This way we can isolate the error handling and exit trapping.
   The `seed` function is concerned only with modifying the database.
  */
  async function runSeed() {
    console.log('seeding...')
    try {
      await seedDB()
    } catch (err) {
      console.error(err)
      process.exitCode = 1
    } finally {
      console.log('closing db connection')
      await db.close()
      console.log('db connection closed')
    }
  }
  
  /*
    Execute the `seed` function, IF we ran this module directly (`node seed`).
    `Async` functions always return a promise, so we can use `catch` to handle
    any errors that might occur inside of `seed`.
  */
  if (module === require.main) {
    runSeed()
  }
  
  // we export the seed function for testing purposes (see `./seed.spec.js`)
  // module.exports = seed
  