Skip to content

Add a network column across all Prisma models #159

Description

@Miracle656

Background

Wraith's schema has no network dimension — every table keys on contract/address/ledger only. If a mainnet instance and a testnet instance ever share a database, records collide: eventId is globally @unique on TokenTransfer/HostFnLog/NftTransfer (RPC paging tokens can repeat across networks and silently overwrite), and IndexerState/BackfillCursor are singleton rows (@id @default(1)) — one cursor for the whole DB. Dual-network is impossible until storage is network-aware.

What to build

Add a network field ("testnet" | "mainnet") to every model and fold it into every uniqueness constraint and query.

Key files

  • prisma/schema.prisma — add network to TokenTransfer, HostFnLog, NftTransfer, NftMetadata, AccountSummary, WebhookSubscription/Delivery, IndexerState, IndexerCheckpoint, BackfillCursor, RetentionJobRun
  • src/db.ts — thread network into every read/write
  • a new Prisma migration

Suggested execution

git checkout -b feat/network-column
  1. Add network String @default("testnet") to each model
  2. Change eventId @unique@@unique([network, eventId]); make IndexerState/BackfillCursor keyed by network instead of the singleton id=1
  3. Update AccountSummary (@@unique([network, address])) and NftMetadata (@@unique([network, contractId, tokenId]))
  4. Regenerate: npx prisma migrate dev --name add-network
  5. Update every query in src/db.ts to pass/filter network

Acceptance criteria

  • Every model carries network; all @unique/@@unique keys include it
  • IndexerState/BackfillCursor are per-network, not singleton rows
  • Migration applies cleanly on a fresh DB
  • Existing queries updated and tests green

Drips Wave · Complexity: Advanced · 200 points


Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions