heroku 10.7.1-beta.0 → 10.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/pg/upgrade/cancel.d.ts +13 -0
- package/lib/commands/pg/upgrade/cancel.js +53 -0
- package/lib/commands/pg/upgrade/dryrun.d.ts +14 -0
- package/lib/commands/pg/upgrade/dryrun.js +54 -0
- package/lib/commands/pg/upgrade/index.js +76 -0
- package/lib/commands/pg/upgrade/prepare.d.ts +14 -0
- package/lib/commands/pg/upgrade/prepare.js +54 -0
- package/lib/commands/pg/upgrade/run.d.ts +16 -0
- package/lib/commands/pg/upgrade/run.js +98 -0
- package/lib/commands/pg/upgrade/wait.d.ts +16 -0
- package/lib/commands/pg/upgrade/wait.js +103 -0
- package/lib/lib/pg/types.d.ts +15 -0
- package/lib/lib/pg/util.d.ts +1 -0
- package/lib/lib/pg/util.js +5 -1
- package/oclif.manifest.json +465 -188
- package/package.json +2 -2
- package/lib/commands/pg/upgrade.js +0 -59
- /package/lib/commands/pg/{upgrade.d.ts → upgrade/index.d.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@heroku-cli/command';
|
|
2
|
+
export default class Upgrade extends Command {
|
|
3
|
+
static topic: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
confirm: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static args: {
|
|
10
|
+
database: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
7
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
8
|
+
const host_1 = require("../../../lib/pg/host");
|
|
9
|
+
const util_1 = require("../../../lib/pg/util");
|
|
10
|
+
const confirmCommand_1 = require("../../../lib/confirmCommand");
|
|
11
|
+
const nls_1 = require("../../../nls");
|
|
12
|
+
class Upgrade extends command_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags, args } = await this.parse(Upgrade);
|
|
15
|
+
const { app, confirm } = flags;
|
|
16
|
+
const { database } = args;
|
|
17
|
+
const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
|
|
18
|
+
if ((0, util_1.legacyEssentialPlan)(db))
|
|
19
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
|
|
20
|
+
if ((0, util_1.essentialNumPlan)(db))
|
|
21
|
+
core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:cancel')} on Essential-tier databases. You can only use this command on Standard-tier and higher leader databases.`);
|
|
22
|
+
const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
|
|
23
|
+
if (replica.following)
|
|
24
|
+
core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:cancel')} on follower databases. You can only use this command on Standard-tier and higher leader databases.`);
|
|
25
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
26
|
+
Destructive action
|
|
27
|
+
You're canceling the scheduled version upgrade for ${color_1.default.addon(db.name)}.
|
|
28
|
+
|
|
29
|
+
You can't undo this action.
|
|
30
|
+
`));
|
|
31
|
+
try {
|
|
32
|
+
core_1.ux.action.start(`Cancelling upgrade on ${color_1.default.addon(db.name)}`);
|
|
33
|
+
const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/cancel`, { hostname: (0, host_1.default)(), body: {} });
|
|
34
|
+
core_1.ux.action.stop('done\n' + (0, util_1.formatResponseWithCommands)(response.body.message));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const response = error;
|
|
38
|
+
core_1.ux.error((0, util_1.formatResponseWithCommands)(response.body.message) + `\n\nError ID: ${response.body.id}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Upgrade;
|
|
43
|
+
Upgrade.topic = 'pg';
|
|
44
|
+
Upgrade.description = (0, tsheredoc_1.default)(`
|
|
45
|
+
cancels a scheduled upgrade. You can't cancel a version upgrade that's in progress.
|
|
46
|
+
`);
|
|
47
|
+
Upgrade.flags = {
|
|
48
|
+
confirm: command_1.flags.string({ char: 'c' }),
|
|
49
|
+
app: command_1.flags.app({ required: true }),
|
|
50
|
+
};
|
|
51
|
+
Upgrade.args = {
|
|
52
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')} ${(0, nls_1.nls)('pg:database:arg:description:default:suffix')}` }),
|
|
53
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@heroku-cli/command';
|
|
2
|
+
export default class Upgrade extends Command {
|
|
3
|
+
static topic: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
confirm: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
database: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
7
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
8
|
+
const host_1 = require("../../../lib/pg/host");
|
|
9
|
+
const util_1 = require("../../../lib/pg/util");
|
|
10
|
+
const confirmCommand_1 = require("../../../lib/confirmCommand");
|
|
11
|
+
const nls_1 = require("../../../nls");
|
|
12
|
+
class Upgrade extends command_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags, args } = await this.parse(Upgrade);
|
|
15
|
+
const { app, version, confirm } = flags;
|
|
16
|
+
const { database } = args;
|
|
17
|
+
const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
|
|
18
|
+
if ((0, util_1.legacyEssentialPlan)(db))
|
|
19
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
|
|
20
|
+
if ((0, util_1.essentialNumPlan)(db))
|
|
21
|
+
core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:dryrun')} on Essential-tier databases. You can only use this command on Standard-tier and higher leader databases.`);
|
|
22
|
+
const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
|
|
23
|
+
const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
|
|
24
|
+
if (replica.following)
|
|
25
|
+
core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:dryrun')} on follower databases. You can only use this command on Standard-tier and higher leader databases.`);
|
|
26
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
27
|
+
Destructive action
|
|
28
|
+
This command starts a test upgrade for ${color_1.default.addon(db.name)} to ${versionPhrase}.
|
|
29
|
+
`));
|
|
30
|
+
try {
|
|
31
|
+
const data = { version };
|
|
32
|
+
core_1.ux.action.start(`Starting a test upgrade on ${color_1.default.addon(db.name)}`);
|
|
33
|
+
const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/dry_run`, { hostname: (0, host_1.default)(), body: data });
|
|
34
|
+
core_1.ux.action.stop('done\n' + (0, util_1.formatResponseWithCommands)(response.body.message));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const response = error;
|
|
38
|
+
core_1.ux.error((0, util_1.formatResponseWithCommands)(response.body.message) + `\n\nError ID: ${response.body.id}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Upgrade;
|
|
43
|
+
Upgrade.topic = 'pg';
|
|
44
|
+
Upgrade.description = (0, tsheredoc_1.default)(`
|
|
45
|
+
simulates a Postgres version upgrade on a Standard-tier and higher leader database by creating and upgrading a follower database. Heroku sends the results of the test upgrade via email.
|
|
46
|
+
`);
|
|
47
|
+
Upgrade.flags = {
|
|
48
|
+
confirm: command_1.flags.string({ char: 'c' }),
|
|
49
|
+
version: command_1.flags.string({ char: 'v', description: 'Postgres version to upgrade to' }),
|
|
50
|
+
app: command_1.flags.app({ required: true }),
|
|
51
|
+
};
|
|
52
|
+
Upgrade.args = {
|
|
53
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')} ${(0, nls_1.nls)('pg:database:arg:description:default:suffix')}` }),
|
|
54
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
7
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
8
|
+
const host_1 = require("../../../lib/pg/host");
|
|
9
|
+
const util_1 = require("../../../lib/pg/util");
|
|
10
|
+
const confirmCommand_1 = require("../../../lib/confirmCommand");
|
|
11
|
+
const nls_1 = require("../../../nls");
|
|
12
|
+
class Upgrade extends command_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags, args } = await this.parse(Upgrade);
|
|
15
|
+
const { app, version, confirm } = flags;
|
|
16
|
+
const { database } = args;
|
|
17
|
+
const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
|
|
18
|
+
if ((0, util_1.legacyEssentialPlan)(db))
|
|
19
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade')} on Essential-tier databases and follower databases on Standard-tier and higher plans.`);
|
|
20
|
+
const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
|
|
21
|
+
const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
|
|
22
|
+
if (replica.following) {
|
|
23
|
+
const { body: configVars } = await this.heroku.get(`/apps/${app}/config-vars`);
|
|
24
|
+
const origin = (0, util_1.databaseNameFromUrl)(replica.following, configVars);
|
|
25
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
26
|
+
We're deprecating this command. To upgrade your database's Postgres version, use the new ${color_1.default.cmd('pg:upgrade:*')} subcommands. See https://devcenter.heroku.com/changelog-items/3179.
|
|
27
|
+
|
|
28
|
+
Destructive action
|
|
29
|
+
You're upgrading ${color_1.default.addon(db.name)} to ${versionPhrase}. The database will stop following ${origin} and become writable.
|
|
30
|
+
|
|
31
|
+
You can't undo this action.
|
|
32
|
+
`));
|
|
33
|
+
}
|
|
34
|
+
else if ((0, util_1.essentialNumPlan)(db)) {
|
|
35
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
36
|
+
We're deprecating this command. To upgrade your database's Postgres version, use the new ${color_1.default.cmd('pg:upgrade:*')} subcommands. See https://devcenter.heroku.com/changelog-items/3179.
|
|
37
|
+
|
|
38
|
+
Destructive action
|
|
39
|
+
You're upgrading ${color_1.default.addon(db.name)} to ${versionPhrase}.
|
|
40
|
+
|
|
41
|
+
You can't undo this action.
|
|
42
|
+
`));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
core_1.ux.warn((0, tsheredoc_1.default)(`
|
|
46
|
+
We're deprecating this command. To upgrade your database's Postgres version, use the new ${color_1.default.cmd('pg:upgrade:*')} subcommands. See https://devcenter.heroku.com/changelog-items/3179.`));
|
|
47
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade')} on Essential-tier databases and follower databases on Standard-tier and higher plans.`);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const data = { version };
|
|
51
|
+
core_1.ux.action.start(`Starting upgrade on ${color_1.default.addon(db.name)}`);
|
|
52
|
+
const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade`, { hostname: (0, host_1.default)(), body: data });
|
|
53
|
+
core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const response = error;
|
|
57
|
+
core_1.ux.error((0, tsheredoc_1.default)(`${(0, util_1.formatResponseWithCommands)(response.body.message)}\n\nError ID: ${response.body.id}`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = Upgrade;
|
|
62
|
+
Upgrade.topic = 'pg';
|
|
63
|
+
Upgrade.description = (0, tsheredoc_1.default)(`
|
|
64
|
+
We're deprecating this command. To upgrade your database's Postgres version, use the new ${color_1.default.cmd('pg:upgrade:*')} subcommands. See https://devcenter.heroku.com/changelog-items/3179.
|
|
65
|
+
|
|
66
|
+
For an Essential-tier plan, this command upgrades the database's Postgres version. For a Standard-tier and higher plan, this command unfollows the leader database before upgrading the Postgres version.
|
|
67
|
+
`);
|
|
68
|
+
Upgrade.flags = {
|
|
69
|
+
confirm: command_1.flags.string({ char: 'c' }),
|
|
70
|
+
version: command_1.flags.string({ char: 'v', description: 'Postgres version to upgrade to' }),
|
|
71
|
+
app: command_1.flags.app({ required: true }),
|
|
72
|
+
remote: command_1.flags.remote(),
|
|
73
|
+
};
|
|
74
|
+
Upgrade.args = {
|
|
75
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')} ${(0, nls_1.nls)('pg:database:arg:description:default:suffix')}` }),
|
|
76
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@heroku-cli/command';
|
|
2
|
+
export default class Upgrade extends Command {
|
|
3
|
+
static topic: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
confirm: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
database: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
7
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
8
|
+
const host_1 = require("../../../lib/pg/host");
|
|
9
|
+
const util_1 = require("../../../lib/pg/util");
|
|
10
|
+
const confirmCommand_1 = require("../../../lib/confirmCommand");
|
|
11
|
+
const nls_1 = require("../../../nls");
|
|
12
|
+
class Upgrade extends command_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags, args } = await this.parse(Upgrade);
|
|
15
|
+
const { app, version, confirm } = flags;
|
|
16
|
+
const { database } = args;
|
|
17
|
+
const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
|
|
18
|
+
if ((0, util_1.legacyEssentialPlan)(db))
|
|
19
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
|
|
20
|
+
if ((0, util_1.essentialNumPlan)(db))
|
|
21
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade:prepare')} on Standard-tier and higher leader databases. For Essential-tier databases, use ${color_1.default.cmd('heroku pg:upgrade:run')} instead.`);
|
|
22
|
+
const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
|
|
23
|
+
const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
|
|
24
|
+
if (replica.following)
|
|
25
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade:prepare')} on Standard-tier and higher leader databases. For follower databases, use ${color_1.default.cmd('heroku pg:upgrade:run')} instead.`);
|
|
26
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
27
|
+
Destructive action
|
|
28
|
+
This command prepares the upgrade for ${color_1.default.addon(db.name)} to ${versionPhrase} and schedules to upgrade it during the next available maintenance window.
|
|
29
|
+
`));
|
|
30
|
+
try {
|
|
31
|
+
const data = { version };
|
|
32
|
+
core_1.ux.action.start(`Preparing upgrade on ${color_1.default.addon(db.name)}`);
|
|
33
|
+
const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/prepare`, { hostname: (0, host_1.default)(), body: data });
|
|
34
|
+
core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const response = error;
|
|
38
|
+
core_1.ux.error((0, tsheredoc_1.default)(`${(0, util_1.formatResponseWithCommands)(response.body.message)}\n\nError ID: ${response.body.id}`));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Upgrade;
|
|
43
|
+
Upgrade.topic = 'pg';
|
|
44
|
+
Upgrade.description = (0, tsheredoc_1.default)(`
|
|
45
|
+
prepares the upgrade for Standard-tier and higher leader databases and schedules it for the next available maintenance window. To start a version upgrade on Essential-tier and follower databases, use ${color_1.default.cmd('heroku pg:upgrade:run')} instead.
|
|
46
|
+
`);
|
|
47
|
+
Upgrade.flags = {
|
|
48
|
+
confirm: command_1.flags.string({ char: 'c' }),
|
|
49
|
+
version: command_1.flags.string({ char: 'v', description: 'Postgres version to upgrade to' }),
|
|
50
|
+
app: command_1.flags.app({ required: true }),
|
|
51
|
+
};
|
|
52
|
+
Upgrade.args = {
|
|
53
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')} ${(0, nls_1.nls)('pg:database:arg:description:default:suffix')}` }),
|
|
54
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from '@heroku-cli/command';
|
|
2
|
+
export default class Upgrade extends Command {
|
|
3
|
+
static topic: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
confirm: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
remote: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
static args: {
|
|
13
|
+
database: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
7
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
8
|
+
const host_1 = require("../../../lib/pg/host");
|
|
9
|
+
const util_1 = require("../../../lib/pg/util");
|
|
10
|
+
const confirmCommand_1 = require("../../../lib/confirmCommand");
|
|
11
|
+
const nls_1 = require("../../../nls");
|
|
12
|
+
class Upgrade extends command_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags, args } = await this.parse(Upgrade);
|
|
15
|
+
const { app, version, confirm } = flags;
|
|
16
|
+
const { database } = args;
|
|
17
|
+
const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
|
|
18
|
+
if ((0, util_1.legacyEssentialPlan)(db))
|
|
19
|
+
core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
|
|
20
|
+
const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
|
|
21
|
+
const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
|
|
22
|
+
if ((0, util_1.essentialNumPlan)(db)) {
|
|
23
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
24
|
+
Destructive action
|
|
25
|
+
You're upgrading ${color_1.default.addon(db.name)} to ${versionPhrase}.
|
|
26
|
+
|
|
27
|
+
You can't undo this action.
|
|
28
|
+
`));
|
|
29
|
+
}
|
|
30
|
+
else if (replica.following) {
|
|
31
|
+
const { body: configVars } = await this.heroku.get(`/apps/${app}/config-vars`);
|
|
32
|
+
const origin = (0, util_1.databaseNameFromUrl)(replica.following, configVars);
|
|
33
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
34
|
+
Destructive action
|
|
35
|
+
You're upgrading ${color_1.default.addon(db.name)} to ${versionPhrase}. The database will stop following ${origin} and become writable.
|
|
36
|
+
|
|
37
|
+
You can't undo this action.
|
|
38
|
+
`));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
|
|
42
|
+
Destructive action
|
|
43
|
+
You're upgrading the Postgres version on ${color_1.default.addon(db.name)}. This action also upgrades any followers on the database.
|
|
44
|
+
|
|
45
|
+
You can't undo this action.
|
|
46
|
+
`));
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const data = { version };
|
|
50
|
+
core_1.ux.action.start(`Starting upgrade on ${color_1.default.addon(db.name)}`);
|
|
51
|
+
const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/run`, { hostname: (0, host_1.default)(), body: data });
|
|
52
|
+
core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof Error && 'body' in error) {
|
|
56
|
+
const response = error;
|
|
57
|
+
core_1.ux.error((0, tsheredoc_1.default)(`${(0, util_1.formatResponseWithCommands)(response.body.message)}\n\nError ID: ${response.body.id}`));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = Upgrade;
|
|
66
|
+
Upgrade.topic = 'pg';
|
|
67
|
+
Upgrade.description = (0, tsheredoc_1.default)(`
|
|
68
|
+
starts a Postgres version upgrade
|
|
69
|
+
|
|
70
|
+
On Essential-tier databases, this command upgrades the database's Postgres version.
|
|
71
|
+
|
|
72
|
+
On Standard-tier and higher leader databases, this command runs a previously scheduled Postgres version upgrade. You must run ${color_1.default.cmd('pg:upgrade:prepare')} before this command to schedule a version upgrade.
|
|
73
|
+
|
|
74
|
+
On follower databases, this command unfollows the leader database before upgrading the follower's Postgres version.
|
|
75
|
+
`);
|
|
76
|
+
Upgrade.examples = [
|
|
77
|
+
(0, tsheredoc_1.default) `
|
|
78
|
+
# Upgrade an Essential-tier database to a specific version
|
|
79
|
+
$ heroku pg:upgrade:run postgresql-curved-12345 --version 14 --app myapp
|
|
80
|
+
`,
|
|
81
|
+
(0, tsheredoc_1.default) `
|
|
82
|
+
# Upgrade a Standard-tier follower database to the latest supported version
|
|
83
|
+
$ heroku pg:upgrade:run HEROKU_POSTGRESQL_BLUE_URL --app myapp
|
|
84
|
+
`,
|
|
85
|
+
(0, tsheredoc_1.default) `
|
|
86
|
+
# Run a previously scheduled upgrade on a Standard-tier leader database
|
|
87
|
+
$ heroku pg:upgrade:run DATABASE_URL --app myapp
|
|
88
|
+
`,
|
|
89
|
+
];
|
|
90
|
+
Upgrade.flags = {
|
|
91
|
+
confirm: command_1.flags.string({ char: 'c' }),
|
|
92
|
+
version: command_1.flags.string({ char: 'v', description: 'Postgres version to upgrade to' }),
|
|
93
|
+
app: command_1.flags.app({ required: true }),
|
|
94
|
+
remote: command_1.flags.remote({ char: 'r' }),
|
|
95
|
+
};
|
|
96
|
+
Upgrade.args = {
|
|
97
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')} ${(0, nls_1.nls)('pg:database:arg:description:default:suffix')}` }),
|
|
98
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from '@heroku-cli/command';
|
|
2
|
+
export default class Wait extends Command {
|
|
3
|
+
static topic: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
'wait-interval': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
'no-notify': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
remote: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static examples: string[];
|
|
12
|
+
static args: {
|
|
13
|
+
database: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@heroku-cli/color");
|
|
4
|
+
const command_1 = require("@heroku-cli/command");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const debug_1 = require("debug");
|
|
7
|
+
const tsheredoc_1 = require("tsheredoc");
|
|
8
|
+
const fetcher_1 = require("../../../lib/pg/fetcher");
|
|
9
|
+
const host_1 = require("../../../lib/pg/host");
|
|
10
|
+
const notify_1 = require("../../../lib/notify");
|
|
11
|
+
const http_call_1 = require("@heroku/http-call");
|
|
12
|
+
const nls_1 = require("../../../nls");
|
|
13
|
+
const util_1 = require("../../../lib/pg/util");
|
|
14
|
+
const wait = (ms) => new Promise(resolve => {
|
|
15
|
+
setTimeout(resolve, ms);
|
|
16
|
+
});
|
|
17
|
+
class Wait extends command_1.Command {
|
|
18
|
+
async run() {
|
|
19
|
+
const { flags, args } = await this.parse(Wait);
|
|
20
|
+
const { app, 'wait-interval': waitInterval } = flags;
|
|
21
|
+
const dbName = args.database;
|
|
22
|
+
const pgDebug = (0, debug_1.default)('pg');
|
|
23
|
+
const waitFor = async (db) => {
|
|
24
|
+
const interval = (!waitInterval || waitInterval < 0) ? 5 : waitInterval;
|
|
25
|
+
let status;
|
|
26
|
+
let waiting = false;
|
|
27
|
+
let retries = 20;
|
|
28
|
+
const notFoundMessage = 'Waiting to provision...';
|
|
29
|
+
while (true) {
|
|
30
|
+
try {
|
|
31
|
+
({ body: status } = await this.heroku.get(`/client/v11/databases/${db.id}/upgrade/wait_status`, { hostname: (0, host_1.default)() }));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof http_call_1.HTTPError && (!retries || error.statusCode !== 404)) {
|
|
35
|
+
const httpError = error;
|
|
36
|
+
pgDebug(httpError);
|
|
37
|
+
throw httpError;
|
|
38
|
+
}
|
|
39
|
+
retries--;
|
|
40
|
+
status = { 'waiting?': true, message: notFoundMessage };
|
|
41
|
+
}
|
|
42
|
+
let message = (0, util_1.formatResponseWithCommands)(status.message);
|
|
43
|
+
if (status.step)
|
|
44
|
+
message = (0, tsheredoc_1.default)(`(${status.step}) ${message}`);
|
|
45
|
+
if (status['error?']) {
|
|
46
|
+
(0, notify_1.default)('error', `${db.name} ${message}`, false);
|
|
47
|
+
core_1.ux.error(message || '', { exit: 1 });
|
|
48
|
+
}
|
|
49
|
+
if (!status['waiting?']) {
|
|
50
|
+
if (waiting) {
|
|
51
|
+
core_1.ux.action.stop(message);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
core_1.ux.log((0, tsheredoc_1.default)(`Waiting for database ${color_1.default.yellow(db.name)}... ${message}`));
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!waiting) {
|
|
59
|
+
waiting = true;
|
|
60
|
+
core_1.ux.action.start(`Waiting for database ${color_1.default.yellow(db.name)}`, message);
|
|
61
|
+
}
|
|
62
|
+
core_1.ux.action.status = message;
|
|
63
|
+
await wait(interval * 1000);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
let dbs = [];
|
|
67
|
+
if (dbName) {
|
|
68
|
+
dbs = [await (0, fetcher_1.getAddon)(this.heroku, app, dbName)];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
core_1.ux.error((0, tsheredoc_1.default)('You must provide a database. Run `--help` for more information on the command.'));
|
|
72
|
+
}
|
|
73
|
+
for (const db of dbs) {
|
|
74
|
+
await waitFor(db);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = Wait;
|
|
79
|
+
Wait.topic = 'pg';
|
|
80
|
+
Wait.description = 'provides the status of an upgrade and blocks it until the operation is complete';
|
|
81
|
+
Wait.flags = {
|
|
82
|
+
'wait-interval': command_1.flags.integer({ description: 'how frequently to poll in seconds (to avoid rate limiting)' }),
|
|
83
|
+
'no-notify': command_1.flags.boolean({ description: 'do not show OS notification' }),
|
|
84
|
+
app: command_1.flags.app({ required: true }),
|
|
85
|
+
remote: command_1.flags.remote(),
|
|
86
|
+
};
|
|
87
|
+
Wait.examples = [
|
|
88
|
+
(0, tsheredoc_1.default)(`
|
|
89
|
+
# Wait for upgrade to complete with default settings
|
|
90
|
+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp
|
|
91
|
+
`),
|
|
92
|
+
(0, tsheredoc_1.default)(`
|
|
93
|
+
# Wait with custom polling interval
|
|
94
|
+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp --wait-interval 10
|
|
95
|
+
`),
|
|
96
|
+
(0, tsheredoc_1.default)(`
|
|
97
|
+
# Wait without showing OS notifications
|
|
98
|
+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp --no-notify
|
|
99
|
+
`),
|
|
100
|
+
];
|
|
101
|
+
Wait.args = {
|
|
102
|
+
database: core_1.Args.string({ description: `${(0, nls_1.nls)('pg:database:arg:description')}` }),
|
|
103
|
+
};
|
package/lib/lib/pg/types.d.ts
CHANGED
|
@@ -94,6 +94,12 @@ export declare type PgStatus = {
|
|
|
94
94
|
'error?': boolean;
|
|
95
95
|
message: string;
|
|
96
96
|
};
|
|
97
|
+
export declare type PgUpgradeStatus = {
|
|
98
|
+
'waiting?': boolean;
|
|
99
|
+
'error?': boolean;
|
|
100
|
+
message: string;
|
|
101
|
+
step: string;
|
|
102
|
+
};
|
|
97
103
|
declare type TenantInfoNames = 'Plan' | 'Status' | 'Connections' | 'PG Version' | 'Created' | 'Data Size' | 'Tables' | 'Fork/Follow' | 'Rollback' | 'Continuous Protection' | 'Billing App' | 'Add-on';
|
|
98
104
|
export declare type TenantInfo = {
|
|
99
105
|
name: TenantInfoNames;
|
|
@@ -114,6 +120,15 @@ export declare type PgDatabaseTenant = {
|
|
|
114
120
|
info: Array<TenantInfo>;
|
|
115
121
|
};
|
|
116
122
|
export declare type PgDatabase = PgDatabaseService & PgDatabaseTenant;
|
|
123
|
+
export declare type PgUpgradeResponse = {
|
|
124
|
+
message: string;
|
|
125
|
+
};
|
|
126
|
+
export declare type PgUpgradeError = {
|
|
127
|
+
body: {
|
|
128
|
+
id: string;
|
|
129
|
+
message: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
117
132
|
export declare type AddOnWithPlan = Required<Heroku.AddOnAttachment['addon']> & {
|
|
118
133
|
plan: Required<Heroku.AddOn['plan']>;
|
|
119
134
|
};
|
package/lib/lib/pg/util.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function essentialPlan(addon: AddOnAttachmentWithConfigVarsAndPla
|
|
|
9
9
|
export declare function getConfigVarNameFromAttachment(attachment: Required<AddOnAttachment & {
|
|
10
10
|
addon: AddOnAttachmentWithConfigVarsAndPlan;
|
|
11
11
|
}>, config?: Record<string, string>): string;
|
|
12
|
+
export declare function formatResponseWithCommands(response: string): string;
|
|
12
13
|
export declare function presentCredentialAttachments(app: string, credAttachments: Required<AddOnAttachment>[], credentials: CredentialsInfo, cred: string): string;
|
|
13
14
|
export declare type ConnectionDetails = {
|
|
14
15
|
user: string;
|
package/lib/lib/pg/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parsePostgresConnectionString = exports.databaseNameFromUrl = exports.configVarNamesFromValue = exports.bastionKeyPlan = exports.getConnectionDetails = exports.presentCredentialAttachments = exports.getConfigVarNameFromAttachment = exports.essentialPlan = exports.legacyEssentialPlan = exports.essentialNumPlan = exports.getConfigVarName = void 0;
|
|
3
|
+
exports.parsePostgresConnectionString = exports.databaseNameFromUrl = exports.configVarNamesFromValue = exports.bastionKeyPlan = exports.getConnectionDetails = exports.presentCredentialAttachments = exports.formatResponseWithCommands = exports.getConfigVarNameFromAttachment = exports.essentialPlan = exports.legacyEssentialPlan = exports.essentialNumPlan = exports.getConfigVarName = void 0;
|
|
4
4
|
const color_1 = require("@heroku-cli/color");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const debug_1 = require("debug");
|
|
@@ -39,6 +39,10 @@ function getConfigVarNameFromAttachment(attachment, config = {}) {
|
|
|
39
39
|
return getConfigVarName(configVars);
|
|
40
40
|
}
|
|
41
41
|
exports.getConfigVarNameFromAttachment = getConfigVarNameFromAttachment;
|
|
42
|
+
function formatResponseWithCommands(response) {
|
|
43
|
+
return response.replace(/`(.*?)`/g, (_, word) => color_1.default.cmd(word));
|
|
44
|
+
}
|
|
45
|
+
exports.formatResponseWithCommands = formatResponseWithCommands;
|
|
42
46
|
function presentCredentialAttachments(app, credAttachments, credentials, cred) {
|
|
43
47
|
const isForeignApp = (attOrAddon) => attOrAddon.app.name === app ? 0 : 1;
|
|
44
48
|
const comparators = [
|