You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
734 B

  1. const { Client } = require('pg')
  2. const fs = require('fs')
  3. const path = require('path')
  4. const yaml = require('js-yaml')
  5. let config = {}
  6. try {
  7. conf = yaml.safeLoad(
  8. cfgHelper.parseConfigValue(
  9. fs.readFileSync(path.join(process.cwd(), 'dev/docker/config.yml'), 'utf8')
  10. )
  11. )
  12. } catch (err) {
  13. console.error(err.message)
  14. process.exit(1)
  15. }
  16. const client = new Client({
  17. user: config.db.username,
  18. host: config.db.host,
  19. database: config.db.database,
  20. password: config.db.password,
  21. port: config.db.port,
  22. })
  23. async function main () {
  24. await client.connect()
  25. await client.query('DROP SCHEMA public CASCADE;')
  26. await client.query('CREATE SCHEMA public;')
  27. await client.end()
  28. console.info('Success.')
  29. }
  30. main()