feat: Add script to clean orphaned reference records

Instances that accumulated project managers, favorites, board memberships
or board subscriptions pointing at a project or board that no longer exists
had no way to find or clear them.

The script reports by default and only deletes with `--apply`, which first
asks whether a backup exists and refuses outright without a terminal to ask
on. It removes nothing but reference rows: structural orphans such as a
board without a project carry user content, and a membership whose
denormalized project is stale still grants real access to an existing
board, so both are reported and left alone.
This commit is contained in:
Daniel Hiller
2026-08-26 09:31:18 +02:00
parent 2d289cd3d5
commit d7da44efe4
3 changed files with 188 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@
"scripts": {
"build": "node build.js",
"console": "dotenv sails console",
"db:clean-orphaned-records": "node db/clean-orphaned-records.js",
"db:create-admin-user": "node db/create-admin-user.js",
"db:init": "node db/init.js",
"db:migrate": "knex migrate:latest --cwd db",