Skip to content

fix/error: relation "failed_relay_publishes" does not exist#225

Merged
calvadev merged 11 commits intoshopstr-eng:mainfrom
RiH-137:fix/added-indexes-migration-support-in-DB
Mar 11, 2026
Merged

fix/error: relation "failed_relay_publishes" does not exist#225
calvadev merged 11 commits intoshopstr-eng:mainfrom
RiH-137:fix/added-indexes-migration-support-in-DB

Conversation

@RiH-137
Copy link
Contributor

@RiH-137 RiH-137 commented Feb 14, 2026

…creation + migration support in DB

Description

error: relation "failed_relay_publishes" does not exist
code: 42P01

Resolved or fixed issue

#224

Root Cause

  1. get-failed-publishes queried failed_relay_publishes before ensuring the table exists.
  2. The same endpoint also joined a non-existent events table.
  3. Failed publish tracking did not consistently store event payload (event_data) needed for retries.

Solution

  1. Added failed_relay_publishes table and indexes in DB schema/bootstrap.
  2. Added migration support for event_data (ALTER TABLE ... ADD COLUMN IF NOT EXISTS).
  3. Updated API endpoints to self-heal schema on request path where needed.
  4. Removed invalid join to events table and fetched data directly from failed_relay_publishes.
  5. Updated client and publish call-sites to send/store full failed event payload.

Files Changed (Path)

  1. db/schema.sql
  2. utils/db/db-service.ts
  3. pages/api/db/get-failed-publishes.ts
  4. pages/api/db/track-failed-publish.ts
  5. pages/api/db/clear-failed-publish.ts
  6. utils/db/db-client.ts
  7. utils/nostr/nostr-helper-functions.ts

Outcome / Impact

  • Fixed 42P01 (relation does not exist) for failed publish endpoints.
  • GET /api/db/get-failed-publishes now returns 200 reliably on fresh/local DBs.
  • Retry flow is now more reliable because event_data is stored and can be replayed.

Copilot AI review requested due to automatic review settings February 14, 2026 13:32
@vercel
Copy link

vercel bot commented Feb 14, 2026

@RiH-137 is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

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 fixes a database error (relation "failed_relay_publishes" does not exist) by adding proper table creation, migration support, and schema initialization. The solution ensures the failed_relay_publishes table exists before querying it, adds the missing event_data column needed for retries, and removes an invalid join to a non-existent events table.

Changes:

  • Added failed_relay_publishes table definition with indexes to database schema and initialization code
  • Implemented migration logic to add event_data column to existing tables
  • Updated failed publish tracking endpoints to self-heal schema and store full event payloads
  • Modified API endpoints to query failed_relay_publishes directly instead of joining non-existent events table

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
db/schema.sql Adds failed_relay_publishes table definition and indexes to the base schema
utils/db/db-service.ts Adds table creation and migration logic for event_data column in initialization
pages/api/db/get-failed-publishes.ts Adds self-healing schema logic and removes invalid events table join
pages/api/db/track-failed-publish.ts Adds schema self-healing and stores full event payload with event_data
pages/api/db/clear-failed-publish.ts Adds table creation logic for consistency across endpoints
utils/db/db-client.ts Updates function signature to accept optional NostrEvent parameter
utils/nostr/nostr-helper-functions.ts Updates call sites to pass full event object to tracking function

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

calvadev and others added 10 commits March 11, 2026 15:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed the creation of the failed_relay_publishes table from the get-failed-publishes API.
Removed the creation of the 'failed_relay_publishes' table from the clear-failed-publish API.
Removed creation of failed_relay_publishes table and its indexes.
Copy link
Collaborator

@calvadev calvadev left a comment

Choose a reason for hiding this comment

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

This was resolved in a separate PR, but still adds useful checks.

@calvadev calvadev merged commit 8a22895 into shopstr-eng:main Mar 11, 2026
1 check failed
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.

3 participants