Skip to content

Commit

Permalink
Support --dropdb option when delete a cloud app (#370)
Browse files Browse the repository at this point in the history
Add a `--dropdb` option so users can optionally drop the app's logical
DB when they delete the app.
This option should be used with cautious.
  • Loading branch information
qianl15 authored Apr 5, 2024
1 parent ec3a24a commit f5de004
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/dbos-cloud/applications/delete-app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosError } from "axios";
import { isCloudAPIErrorResponse, handleAPIErrors, getCloudCredentials, getLogger, retrieveApplicationName } from "../cloudutils.js";

export async function deleteApp(host: string, appName?: string): Promise<number> {
export async function deleteApp(host: string, dropdb: boolean, appName?: string): Promise<number> {
const logger = getLogger()
const userCredentials = getCloudCredentials();
const bearerToken = "Bearer " + userCredentials.token;
Expand All @@ -18,6 +18,9 @@ export async function deleteApp(host: string, appName?: string): Promise<number>
"Content-Type": "application/json",
Authorization: bearerToken,
},
data: {
"dropdb": dropdb,
},
});

logger.info(`Successfully deleted application: ${appName}`);
Expand Down
5 changes: 3 additions & 2 deletions packages/dbos-cloud/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ applicationCommands
.command('delete')
.description('Delete this application')
.argument('[string]', 'application name')
.action(async (appName?: string) => {
const exitCode = await deleteApp(DBOSCloudHost, appName);
.option('--dropdb', 'Drop application database')
.action(async (appName: string | undefined, options: { dropdb: boolean }) => {
const exitCode = await deleteApp(DBOSCloudHost, options.dropdb, appName);
process.exit(exitCode);
});

Expand Down

0 comments on commit f5de004

Please sign in to comment.