Skip to content

ethereumfollowprotocol/indexer

Repository files navigation

Note

The project is under active development.


EFP logo


Start new PR in StackBlitz Codeflow discord chat x account

Ethereum Follow Protocol Indexer

A native Ethereum protocol for following and tagging Ethereum accounts.

Important links

Getting started with development

Prerequisites

Installation

git clone https://github.com/ethereumfollowprotocol/indexer.git && cd indexer

Note

If vscode extensions behave weirdly or you stop getting type hints, run CMD+P and type > Developer: Restart Extension Host to restart the extension host.

# upgrade bun to make sure you have the latest version then install dependencies
bun upgrade && bun install

Environment Variables

cp .env.example .env

Database

Migration files are located in ./db/migrations. dbmate commands:

bunx dbmate --help    # print usage help
bunx dbmate new       # generate a new migration file
bunx dbmate up        # create the database (if it does not already exist) and run any pending migrations
bunx dbmate create    # create the database
bunx dbmate drop      # drop the database
bunx dbmate migrate   # run any pending migrations
bunx dbmate rollback  # roll back the most recent migration
bunx dbmate down      # alias for rollback
bunx dbmate status    # show the status of all migrations (supports --exit-code and --quiet)
bunx dbmate dump      # write the database schema.sql file
bunx dbmate wait      # wait for the database server to become available

Setup

Assuming the efp-database container from compose.yml is running, run the following command to create the database and generate TypeScript types for the database schema:

bun database:up

The command creates the database (if it doesn't exist) and runs migrations (see ./db/migrations).

While still in development (i.e., no production database yet), any database schema we make go directly into this single file: ./db/migrations/20231205052550_init.sql. See next section for updating the database schema.

Updating the database schema

You've updated the sql schema in ./db/migrations/20231205052550_init.sql and want to reflect that in the database container and update the TypeScript types. Run:

Note

Make sure you're not connected to the database through any GUI or client while running this command. Otherwise you will get Error: pq: database "efp" is being accessed by other users.

bun database:reset

This:

  • runs dbmate drop which nukes the efp database, then
  • runs dbmate up which creates the database and runs migrations (aka the single migration file we have in ./db/migrations), then
  • runs kysely-codegen --dialect='postgres' --type-only-imports --log-level='error' which generates TypeScript types for the database schema and writes them to ./src/database/.

TODO: Continue documentation



Follow @ethfollowpr on 𝕏 for updates and join the Discord to get involved.