postgres: a withdrawn consumer keeps its database; retiring renames, never drops (hq issue 241)
This commit is contained in:
@@ -30,6 +30,23 @@ export function getPostgresTools(postgres: PostgresClient): ToolDefinition[] {
|
||||
return { database, command: result.command, rows: result.rows };
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "postgres_retire_database",
|
||||
description:
|
||||
"Take one database out of service on purpose: rename it to <name>_deleted_<date> and lock its owner's login. Nothing is dropped — the data stays on the server under the new name until a person removes it by hand. Repeat the database's name in confirm.",
|
||||
input: {
|
||||
database: { type: "string", description: "the database to retire" },
|
||||
confirm: { type: "string", description: "the same name again, to say this is meant" },
|
||||
},
|
||||
run: async (args) => {
|
||||
const database = String(args.database ?? "");
|
||||
if (!database) throw new Error("postgres_retire_database: database is required");
|
||||
if (String(args.confirm ?? "") !== database) {
|
||||
throw new Error("postgres_retire_database: confirm must repeat the database's name");
|
||||
}
|
||||
return { database, renamedTo: await postgres.retireDatabase(database), dropped: false };
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user