feat: Import .jsonl file with events into the events table#414
feat: Import .jsonl file with events into the events table#414phoenix-server merged 8 commits intocameri:mainfrom
Conversation
|
Hi @cameri, I tested the imports locally and they work fine. Please take a look when you’re free and let me know if you’d like any changes. Thanks! |
|
Thank you. I will send you an events database for you to test this against. Stay tuned. |
src/services/event-import-service.ts
Outdated
| const REPLACEABLE_EVENT_CONFLICT_TARGET = | ||
| '(event_pubkey, event_kind, event_deduplication) ' | ||
| + 'WHERE (event_kind = 0 OR event_kind = 3 OR event_kind = 41 ' | ||
| + 'OR (event_kind >= 10000 AND event_kind < 20000)) ' | ||
| + 'OR (event_kind >= 30000 AND event_kind < 40000)' |
There was a problem hiding this comment.
My concern here is that this query will drift from the queries in the EventRepository over time.
Is there a reason why the event import service essentially re-implements the database layer instead of re-using it?
74476ce to
791c01f
Compare
24406fc to
c076a6a
Compare
|
Hi @cameri, I’ve updated the importer to reuse Ephemeral events are skipped, duplicates are handled gracefully, and progress/errors are reported during import. Am i doing something wrong in this approch? Please let me know. |

Description
Implements a CLI utility for importing NIP-01 events from
.jsonlfiles into the events table.readlineto keep memory usage constant regardless of file size.--batch-size).ON CONFLICT DO NOTHING, replaceable/parameterized replaceable upserts using the existingreplaceable_events_idx, delete event application in stream order, and ephemeral event filtering.Related Issue
Closes #406
Motivation and Context
There's no built-in way to seed a relay with existing data or migrate events from another relay. This adds a straightforward CLI for it.
How Has This Been Tested?
Tested locally against a real PostgreSQL instance , imported 463 events from a .jsonl file and all inserted successfully in ~1s. Progress tracking and final summary both working as expected.
Types of changes
Checklist: