text: 'use strict'
  
  const debug = require('debug')('platziverse:db:setup')
  const inquirer = require('inquirer')
  const chalk = require('chalk')
  const minimist = require('minimist')
  const db = require('./')
  
  const args = minimist(process.argv)
  const prompt = inquirer.createPromptModule()
  async function setup () {
  
    if (!args.yes) {
      const answer = await prompt([
        {
          type: 'confirm',
          name: 'setup',
          message: 'Esto va a destruir la db, ¿esta seguro carechimba?'
        }
      ])
  
      if (!answer.setup) {
        return console.log('Listo, no pasa nada')
      }
    }
    
  
    
    const config = {
      database: process.env.DB_NAME || 'platziverse',
      username: process.env.DB_USER || 'platzi',
      password: process.env.DB_PASS || 'platzi',
      host: process.env.DB_HOST || 'localhost',
      dialect: 'postgres',
      setup: true,
      logging: s => debug(s)
    }
    await db(config).catch(handleFatalError)
  
    console.log('Exito!')
    process.exit(0)
  }
  
  function handleFatalError (err) {
    console.error(`${chalk.red('[fatal error]')} ${err.message}`)
    console.error(err.stack)
    process.exit(1)
  }
  
  setup()
  