From 4198eb27895c731906d388c746a235848852bf20 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 8 Aug 2022 10:54:38 +0200 Subject: [PATCH] Add script to delete projects from the command line for cleanup of ownerless projects (#9106) * Add script for deleting projects via command line GitOrigin-RevId: bc08e4a39986e9d43dd103a14c28b02ca9ce84d9 --- services/web/scripts/soft_delete_project.js | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 services/web/scripts/soft_delete_project.js diff --git a/services/web/scripts/soft_delete_project.js b/services/web/scripts/soft_delete_project.js new file mode 100644 index 0000000000..969a2a1cc4 --- /dev/null +++ b/services/web/scripts/soft_delete_project.js @@ -0,0 +1,27 @@ +const minimist = require('minimist') +const { waitForDb } = require('../app/src/infrastructure/mongodb') +const ProjectDeleter = require('../app/src/Features/Project/ProjectDeleter') + +async function main() { + const argv = minimist(process.argv.slice(2)) + const projectId = argv['project-id'] + + if (!projectId) { + throw new Error('set --project-id') + } + console.log(`Soft deleting project ${projectId}`) + await waitForDb() + + // soft delete, project will be permanently deleted after 90 days + await ProjectDeleter.promises.deleteProject(projectId) +} + +main() + .then(() => { + console.log('Done.') + process.exit(0) + }) + .catch(err => { + console.error(err) + process.exit(1) + })