Skip to content

fix: store research and project tags as bigint[] like news and questions - #4984

Closed
kimskovhusandersen wants to merge 4 commits into
ONEARMY:mainfrom
kimskovhusandersen:fix/tags-column-type
Closed

kimskovhusandersen wants to merge 4 commits into
ONEARMY:mainfrom
kimskovhusandersen:fix/tags-column-type

Conversation

@kimskovhusandersen

@kimskovhusandersen kimskovhusandersen commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

  • 🐛 Bugfix
  • ✨ Feature
  • ♻️ Refactoring
  • ⚡️ Performance
  • 🧪 Tests
  • 🔧 Tools / CI
  • 📝 Documentation
  • 📦 Dependencies

What changed

research.tags and projects.tags were text[], while news.tags and questions.tags are bigint[]. The app writes numeric tag ids to all four, so Postgres was silently casting them to text for research and projects.

This PR makes all four columns bigint[]:

  • New migration 20261011122925_tags_bigint.sql alters both columns with USING tags::bigint[], then drops and recreates get_research and get_projects so they return tags bigint[]. Function bodies are unchanged. No other SQL object references these columns.
  • Declarative schemas supabase/schemas/research.sql and projects.sql updated to match.
  • shared/database.types.ts regenerated with bun run db:types.
  • DBResearchItem.tags, DBProject.tags and IDBContentDoc.tags are number[] | null again. The map(String) / map(Number) conversions added in refactor: type news, question, research and project queries #4978 and refactor: type remaining queries and Supabase clients #4979 are gone.
  • seed.ts wrote the tag name for projects and a stringified id for research. Both now write the numeric id. .snaplet/dataModel.json updated for the two columns.

Verified locally with supabase db reset on a fresh database, seeding, calling both functions, and loading the research and library list and detail pages.

What needs to happen on your side

We have no production database access, so three things for whoever deploys this.

Before deploying, check that every stored tag is numeric. The cast aborts the migration (safely, inside its transaction) on any non-numeric value:

select id, tags from research
where exists (select 1 from unnest(tags) t where t !~ '^[0-9]+$');

select id, tags from projects
where exists (select 1 from unnest(tags) t where t !~ '^[0-9]+$');

If either returns rows, fix or clear those values first.

The migration rewrites the two columns and recreates the two functions. It runs through the normal migration deploy.

This branch is stacked on #4979. Until that merges, its commits show up here too. Only the last commit belongs to this PR.

Screenshots

No UI change

Issue

Closes #4982

Database

  • This PR includes a schema change or migration

Checklist

  • I ran the app and checked this change myself
  • bun run format and bun run test:unit pass
  • Tests added or updated for this change

@cypress

cypress Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

onearmy-community-platform    Run #10292

Run Properties:  status check passed Passed #10292  •  git commit 57e39813e9: fix: store research and project tags as bigint[] like news and questions
Project onearmy-community-platform
Branch Review pull/4984
Run status status check passed Passed #10292
Run duration 09m 44s
Commit git commit 57e39813e9: fix: store research and project tags as bigint[] like news and questions
Committer Kim Skovhus Andersen
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 109
View all changes introduced in this branch ↗︎

kimskovhusandersen and others added 4 commits October 11, 2026 15:19
…ries

Useful-vote routes now reject unsupported content types before writing to the enum column. The duplicate-vote check in PollServiceServer filtered on a poll_id column that poll_votes does not have, so it never matched; it now filters through poll_options. Notifications for legacy content types are filtered out before mapping instead of failing inside the mapper.

Refs ONEARMY#4344

Co-authored-by: Cursor <cursoragent@cursor.com>
Type the remaining server services and profile factories against the
generated Database types and align DBProfile, DBProfileTagJoin and map pin
writes with the actual columns.

Refs ONEARMY#4344

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass the Database type to the server and admin Supabase clients so every
query is checked against the schema, and fix the remaining route mismatches.

Closes ONEARMY#4344

Co-authored-by: Cursor <cursoragent@cursor.com>
@benfurber

Copy link
Copy Markdown
Member

Hey @kimskovhusandersen, how are you getting on with this? :)

@benfurber

Copy link
Copy Markdown
Member

I'll just close this for now, happy for you to pick up again in the future @kimskovhusandersen. :)

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

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

research.tags and projects.tags are text[] columns while news.tags and questions.tags are bigint[]

2 participants