fix/error: relation "failed_relay_publishes" does not exist#225
Conversation
…creation + migration support in DB
|
@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. |
There was a problem hiding this comment.
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_publishestable definition with indexes to database schema and initialization code - Implemented migration logic to add
event_datacolumn to existing tables - Updated failed publish tracking endpoints to self-heal schema and store full event payloads
- Modified API endpoints to query
failed_relay_publishesdirectly instead of joining non-existenteventstable
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.
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.
calvadev
left a comment
There was a problem hiding this comment.
This was resolved in a separate PR, but still adds useful checks.
…creation + migration support in DB
Description
error: relation "failed_relay_publishes" does not exist
code: 42P01
Resolved or fixed issue
#224
Root Cause
get-failed-publishesqueriedfailed_relay_publishesbefore ensuring the table exists.eventstable.event_data) needed for retries.Solution
failed_relay_publishestable and indexes in DB schema/bootstrap.event_data(ALTER TABLE ... ADD COLUMN IF NOT EXISTS).eventstable and fetched data directly fromfailed_relay_publishes.Files Changed (Path)
db/schema.sqlutils/db/db-service.tspages/api/db/get-failed-publishes.tspages/api/db/track-failed-publish.tspages/api/db/clear-failed-publish.tsutils/db/db-client.tsutils/nostr/nostr-helper-functions.tsOutcome / Impact
42P01(relation does not exist) for failed publish endpoints.GET /api/db/get-failed-publishesnow returns200reliably on fresh/local DBs.event_datais stored and can be replayed.