Skip to content

Commit

Permalink
docs: improve 0.7 migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
typedarray committed Jan 6, 2025
1 parent a88d553 commit 82612fb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/pages/docs/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ Key changes:
2. Export all table objects from `ponder.schema.ts`
3. Use `.primaryKey()` to mark the primary key column
4. Columns are nullable by default, use `.notNull()` to add the constraint
5. The `hex` column type now uses `TEXT` instead of `BYTEA`
6. `p.float()` (`DOUBLE PRECISION`) was removed, use `t.doublePrecision()` or `t.real()` instead

The new `onchainTable` function adds several new capabilities.

Expand Down Expand Up @@ -448,9 +450,19 @@ await context.db
await context.db.Account.delete({ id: event.args.from });
await context.db.delete(account, { address: event.args.from });

// findMany -> select
// findMany -> raw SQL select, see below
await context.db.Account.findMany({ where: { balance: { gt: 100n } } });
await context.db.sql.select().from(account).where(eq(account.balance, 100n));

// updateMany -> raw SQL update, see below
await context.db.Player.updateMany({
where: { id: { startsWith: "J" } },
data: { age: 50 },
});
await context.db.sql
.update(player)
.set({ age: 50 })
.where(like(player.id, "J%"));
```

Finally, another migration example for an ERC20 Transfer indexing function using `upsert`.
Expand Down

0 comments on commit 82612fb

Please sign in to comment.