Skip to content

Conversation

@0xSysR3ll
Copy link
Contributor

Description

This PR fixes duplicate user_push_subscription entries by removing them before applying the UNIQUE constraint on (endpoint, userId).

How Has This Been Tested?

  1. Inserted dummy duplicate user_push_subscription entries.
  2. Ran the migration.
  3. Verified that duplicates were removed and the UNIQUE constraint was applied successfully.

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

…ore enforcing unique constraint

Signed-off-by: 0xsysr3ll <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses duplicate entries in the user_push_subscription table by adding a cleanup step before enforcing a unique constraint on the (endpoint, userId) column pair. The migration prevents constraint violation errors when upgrading existing installations that may have accumulated duplicate push subscription records.

Key Changes:

  • Added DELETE query to remove duplicate push subscriptions, keeping only the record with the highest ID for each (endpoint, userId) combination
  • Applied UNIQUE constraint/index on (endpoint, userId) columns after cleanup
  • Implemented the fix consistently for both PostgreSQL and SQLite databases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
server/migration/postgres/1765233385034-AddUniqueConstraintToPushSubscription.ts Adds duplicate removal query and applies UNIQUE constraint for PostgreSQL
server/migration/sqlite/1765233385034-AddUniqueConstraintToPushSubscription.ts Adds duplicate removal query and creates UNIQUE index for SQLite

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fallenbagel fallenbagel enabled auto-merge (squash) January 2, 2026 14:02
@fallenbagel fallenbagel merged commit 0c95b5e into develop Jan 5, 2026
14 checks passed
@fallenbagel fallenbagel deleted the 0xsysr3ll/fix/duplicate-subscriptions branch January 5, 2026 09:54
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.

SQLite duplicate entries (user_push_subscription table)

4 participants