Skip to content

Commit 5d797ef

Browse files
committed
hub/delete-projects: reset more fields and clear more table entries
1 parent d1989d8 commit 5d797ef

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/packages/database/postgres/delete-projects.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ export async function cleanup_old_projects_data(
181181
numProj += 1;
182182
let delRows = 0;
183183

184-
// Clean up data *on* a given project. For now, remove all site licenses.
184+
// Clean up data *on* a given project. For now, remove all site licenses, status and last_active.
185185
await pool.query(
186-
`UPDATE projects SET site_license = NULL WHERE project_id = $1`,
186+
`UPDATE projects
187+
SET site_license = NULL, status = NULL, last_active = NULL, run_quota = NULL
188+
WHERE project_id = $1`,
187189
[project_id],
188190
);
189191

@@ -237,17 +239,23 @@ async function delete_associated_project_data(
237239
L2: WinstonLogger["debug"],
238240
project_id: string,
239241
): Promise<number> {
242+
// TODO: two tables reference a project, but become useless.
243+
// There should be a fallback strategy to move these objects to another project or surface them as being orphaned.
244+
// tables: cloud_filesystems, compute_servers
245+
240246
let total = 0;
241247
// collecting tables, where the primary key is the default (i.e. "id") and
242248
// the field to check is always called "project_id"
243249
const tables = [
244-
"public_paths",
245-
"project_log",
246-
"file_use",
250+
"blobs",
247251
"file_access_log",
252+
"file_use",
248253
"jupyter_api_log",
254+
"mentions",
249255
"openai_chatgpt_log",
250-
"blobs",
256+
"project_log",
257+
"public_paths",
258+
"shopping_cart_items",
251259
] as const;
252260

253261
for (const table of tables) {

0 commit comments

Comments
 (0)