Skip to content

feat(OUT-3697): index workspaceId and parentId on Tasks#1206

Draft
priosshrsth wants to merge 4 commits intomainfrom
anit/out-3697-index-workspaceid-column-in-tasks-table
Draft

feat(OUT-3697): index workspaceId and parentId on Tasks#1206
priosshrsth wants to merge 4 commits intomainfrom
anit/out-3697-index-workspaceid-column-in-tasks-table

Conversation

@priosshrsth
Copy link
Copy Markdown
Collaborator

@priosshrsth priosshrsth commented May 6, 2026

Summary

  • Adds btree indexes on Tasks.workspaceId and Tasks.parentId to drop a 7s query by ~99% (per Supabase analysis on the Linear ticket).
  • Migration uses CREATE INDEX IF NOT EXISTS so it's a no-op in production — indexes will be built ahead of deploy via CREATE INDEX CONCURRENTLY in the Supabase SQL editor to avoid locking writes. Lower envs build them normally.

Production rollout (must run BEFORE merging/deploy)

In the Supabase SQL editor, run each statement individually (CONCURRENTLY cannot run inside a transaction):

CREATE INDEX CONCURRENTLY IF NOT EXISTS "IX_Tasks_workspaceId" ON "Tasks"("workspaceId");
CREATE INDEX CONCURRENTLY IF NOT EXISTS "IX_Tasks_parentId" ON "Tasks"("parentId");

Verify:

SELECT indexname FROM pg_indexes WHERE tablename = 'Tasks';

Once both indexes exist in prod, the Prisma migration becomes a no-op there and just gets recorded in _prisma_migrations.

Test plan

  • Indexes created concurrently in production via Supabase SQL editor (verified with pg_indexes query above)
  • prisma migrate deploy runs cleanly on staging
  • Slow query identified in OUT-3697 returns in expected (sub-second) time after indexes exist
  • No regressions in tasks list / subtask views

🤖 Generated with Claude Code

- add @@index for workspaceId and parentId in Task schema (named
  IX_Tasks_workspaceId, IX_Tasks_parentId)
- new Prisma migration uses CREATE INDEX IF NOT EXISTS so it is a
  no-op in prod once the indexes are created CONCURRENTLY via the
  Supabase SQL editor; lower environments build them normally
- bundled unrelated local updates: bun + node 24 in mise.toml,
  next.config.js -> next.config.ts rename, sentry/next/react bumps
  in package.json + yarn.lock, supabase studio query snippet

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 6, 2026

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment May 6, 2026 1:00pm

Request Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR adds B-tree indexes on Tasks.workspaceId and Tasks.parentId to address a 7-second query identified in OUT-3697, using IF NOT EXISTS so the Prisma migration is a no-op in production after the indexes are pre-built with CONCURRENTLY. It also bundles several unrelated local-dev improvements: a mise.toml update (Bun + Node 24, convenience tasks), next.config.jsnext.config.ts rename, and version bumps for Next, React, and Sentry.

  • Database indexes: Migration SQL and Prisma schema are consistent; the CREATE INDEX IF NOT EXISTS / CONCURRENTLY split is a sound strategy for avoiding table-level write locks in production.
  • Sentry config: hideSourceMaps: true is correctly migrated to the sourcemaps: { disable: true } shape required by @sentry/nextjs v9.
  • Tooling: bun = "latest" in mise.toml and the leftover module.exports in the now-TypeScript config file are minor rough edges worth cleaning up.

Confidence Score: 4/5

Safe to merge once the CONCURRENTLY indexes are confirmed in production; no logic changes touch application code.

The migration and schema changes are straightforward and low-risk. The two minor issues — non-deterministic bun = latest and the module.exports leftover in a .ts file — won't break the build but are worth cleaning up before they cause confusion.

mise.toml (unpinned Bun version) and next.config.ts (module.exports vs export default); the migration SQL and Prisma schema are clean.

Important Files Changed

Filename Overview
prisma/migrations/20260506122850_add_workspaceid_parentid_indexes_to_tasks/migration.sql Adds two B-tree indexes with IF NOT EXISTS; correct no-op strategy for production where CONCURRENTLY indexes are pre-built via the Supabase SQL editor.
prisma/schema/task.prisma Adds @@index declarations for workspaceId and parentId matching the migration; schema and migration are consistent.
next.config.ts Renamed from .js to .ts, converted require to import, updated hideSourceMaps to sourcemaps.disable for Sentry v9; still uses module.exports rather than export default.
mise.toml Adds bun and node 24 tooling with dev/db tasks; bun is pinned to latest rather than a fixed version, which can cause environment drift.
package.json Bumps @sentry/nextjs ^8 to ^9.47.1, next 16.1.1 to ^16.2.4, react/react-dom 19.2.3 to 19.2.5; routine dependency updates.
supabase/snippets/Untitled query 448.sql Reference snippet for running CONCURRENTLY index creation in production; informational only, not executed by Prisma.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[PR merged / prisma migrate deploy] --> B{Index already exists?}
    B -- Yes\n(production: pre-built CONCURRENTLY) --> C[CREATE INDEX IF NOT EXISTS\nis a no-op]
    B -- No\n(staging / local) --> D[CREATE INDEX runs\nnormally]
    C --> E[Migration recorded in _prisma_migrations]
    D --> E
Loading

Comments Outside Diff (1)

  1. next.config.ts, line 31 (link)

    P2 The file was renamed from .js to .ts and now uses ESM import declarations at the top, but still exports via module.exports. The canonical next.config.ts pattern uses export default; mixing ESM imports with a CommonJS export can trip up stricter TypeScript module/moduleResolution settings and is inconsistent with the file extension change.

Reviews (1): Last reviewed commit: "feat(OUT-3697): index workspaceId and pa..." | Re-trigger Greptile

Comment thread mise.toml Outdated
priosshrsth and others added 2 commits May 6, 2026 12:51
…-3697-index-workspaceid-column-in-tasks-table
Keep this PR focused on the Tasks index work — reverting next.config.ts
rename, @sentry/nextjs / next / react bumps, and removing the Supabase
Studio query snippet. mise.toml updates (bun, node 24, dev/db tasks)
intentionally retained.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

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