Skip to content

Clean unused db models and columns#3553

Open
isTravis wants to merge 3 commits intomainfrom
tr/db-clean
Open

Clean unused db models and columns#3553
isTravis wants to merge 3 commits intomainfrom
tr/db-clean

Conversation

@isTravis
Copy link
Copy Markdown
Member

@isTravis isTravis commented Apr 5, 2026

Audited our Sequelize models against the rest of the codebase (imports, includes, queries, client code, workers, etc.) and removed everything that has zero runtime usage. These only existed in model definitions, type schemas, and old migration scripts under tools/.

Before merging, I wan to confirm with the team: does anyone know of external scripts, cron jobs, or direct DB queries that reference any of the below?

Removed tables (6)

Table Notes
CommunityAdmins No queries, no routes, no associations. The ensureUserIsCommunityAdmin utility is unrelated (it checks the Member model).
Merges Legacy from pre-Release days. Only referenced in old tools/ migration scripts.
Organizations Never queried. scopeGet.ts explicitly throws "No such thing as an organization". Community had a BelongsTo Organization association that was never included in any query.
PubManagers Superseded by the Member model. Only referenced in old Firebase migration scripts.
PubVersions Superseded by Releases. Pub model had a HasMany PubVersion association that was never used in any include. Only referenced in old tools/ scripts.
ThreadUsers Most dead of all - wasn't even registered in sequelize.addModels(). Completely orphaned.

Removed columns (7)

Table Column Notes
Users inactive Never read, written, or filtered on anywhere.
Users pubpubV3Id v3 migration artifact.
Communities organizationId FK to the now-removed Organizations table. Always null.
Members organizationId Never set by createMember(). Client useMembers read it but it was always null — that code is also cleaned up here.
PublicPermissions organizationId Never set or queried.
Releases historyKeyMissing One-time data migration flag from 2020. Never read at runtime.
ReviewNews labels Whitelisted for API update but never sent by any client or read by any server code.

Other cleanup

  • Removed Organization-related UI code in DashboardMembers (including two @ts-expect-error comments that acknowledged Organizations "aren't really a thing anymore")
  • Removed PubVersion type export from types/pub.ts
  • Cleaned up mock/storybook data that referenced removed fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant