-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (25 loc) · 1.13 KB
/
index.js
File metadata and controls
32 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict'
const cli = require('heroku-cli-util')
async function run(context, heroku) {
const fetcher = require('../../lib/fetcher')(heroku)
const host = require('../../lib/host')
const util = require('../../lib/util')
const {app, args} = context
const db = await fetcher.addon(app, args.database)
if (util.essentialPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.')
let newPluginMessage = `You can also list the maintenance events for your Postgres database with ${cli.color.cmd('data:maintenances')}.`
newPluginMessage += '\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands'
newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.`
cli.warn(newPluginMessage)
let info = await heroku.get(`/client/v11/databases/${db.id}/maintenance`, {host: host(db)})
cli.log(info.message)
}
module.exports = {
topic: 'pg',
command: 'maintenance',
description: 'show current maintenance information',
needsApp: true,
needsAuth: true,
args: [{name: 'database', optional: true}],
run: cli.command({preauth: true}, run),
}