UNPKG

861 BJavaScriptView Raw
1'use strict'
2
3const cli = require('heroku-cli-util')
4
5async function run(context, heroku) {
6 const host = require('../lib/host')
7 const fetcher = require('../lib/fetcher')(heroku)
8 let { app, args, flags } = context
9 let db = await fetcher.addon(app, args.database)
10
11 await cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
12${cli.color.addon(db.name)} will lose all of its data
13`)
14
15 await cli.action(`Resetting ${cli.color.addon(db.name)}`, async function () {
16 await heroku.put(`/client/v11/databases/${db.id}/reset`, { host: host(db) })
17 }())
18}
19
20module.exports = {
21 topic: 'pg',
22 command: 'reset',
23 description: 'delete all data in DATABASE',
24 needsApp: true,
25 needsAuth: true,
26 args: [{ name: 'database', optional: true }],
27 flags: [{ name: 'confirm', char: 'c', hasValue: true }],
28 run: cli.command({ preauth: true }, run)
29}