Skip to content

backend-stream#958

Open
Securify001 wants to merge 1 commit into
LabsCrypt:mainfrom
Securify001:backend-stream
Open

backend-stream#958
Securify001 wants to merge 1 commit into
LabsCrypt:mainfrom
Securify001:backend-stream

Conversation

@Securify001

Copy link
Copy Markdown

Description

Schema & migration: Replaced @@index([streamId, createdAt]) with @@index([streamId, timestamp]) in backend/prisma/schema.prisma.
Added migration backend/prisma/migrations/20260630120000_add_stream_event_stream_id_timestamp_index/migration.sql:
Creates StreamEvent_streamId_timestamp_idx
Drops unused StreamEvent_streamId_createdAt_idx (with IF EXISTS, since it was only in schema drift and never migrated)

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #833
Closes #834
Closes #835
Closes #836

Changes Made

The listed controllers already match the new index access pattern:

getStreamEvents — where: { streamId } + orderBy: { timestamp }
getStream include — events: { orderBy: { timestamp: 'desc' } }
getUserEvents — orderBy: { timestamp: 'desc' }

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

All targeted tests pass:

stream.controller.test.ts — 10 passed
user.controller.test.ts — 11 passed
integration/streams.test.ts — 12 passed
npx prisma validate passes. Docker/Postgres is not available here, so EXPLAIN-based index verification was not run locally; the migration SQL follows the same pattern as prior index migrations in this repo.
When you have Postgres available, apply with:
cd backend && npx prisma migrate deploy

Migration Guide:

Added migration backend/prisma/migrations/20260630120000_add_stream_event_stream_id_timestamp_index/migration.sql:
Creates StreamEvent_streamId_timestamp_idx
Drops unused StreamEvent_streamId_createdAt_idx (with IF EXISTS, since it was only in schema drift and never migrated)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable

Additional Notes

@ogazboiz

ogazboiz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

heads up: main's ci was broken (the Backend CI and Backend Docker Image CI jobs) until the fixes in #969 and #974 just landed, so the red backend/docker checks on this pr are almost certainly stale, they ran against the broken main. please rebase to re-test against the now-green main: git fetch origin && git rebase origin/main && git push --force-with-lease. once it's green i'll review and merge. (if a non-backend check like Frontend CI is still red after the rebase, that part is a real issue worth a look, since frontend ci was passing on main.)

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