Skip to content

Commit

Permalink
postgresql install
Browse files Browse the repository at this point in the history
  • Loading branch information
rtso committed Jan 17, 2025
1 parent e5a457e commit 3db7939
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Each core processor indexes a specific type of data.
You can explore the [full list of processors](https://github.com/aptos-labs/aptos-indexer-processors/tree/main/rust/sdk-processor/src/processors) and the [complete indexer data schema](https://github.com/aptos-labs/aptos-indexer-processors/blob/main/rust/processor/src/db/postgres/schema.rs).

The Aptos core processors and the [Quickstart Guide](../quickstart.mdx) use [PostgreSQL](https://www.postgresql.org/) as the database and [Diesel](https://diesel.rs/) as the ORM.
However, you are free to choose any database or ORM that fits your needs.
If you'd also like to use PostgreSQL and Diesel, you can follow the instructions in [PostgreSQL Installation](../quickstart.mdx#postgresql-installation).

You're free to use whatever database and ORM you prefer.
Popular alternatives include [SeaORM](https://www.sea-ql.org/SeaORM/) and [SQLx](https://github.com/launchbadge/sqlx).
Setting up a database and using an ORM is beyond the scope of these tutorials.
If you need guidance, refer to the tutorials linked above for more information.
19 changes: 11 additions & 8 deletions apps/nextra/pages/en/build/indexer/indexer-sdk/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,27 @@ You also need the following tools:

- Rust 1.79: [Installation Guide](https://www.rust-lang.org/tools/install)
- Cargo: [Installation Guide](https://doc.rust-lang.org/cargo/getting-started/installation.html#install-rust-and-cargo)
- Diesel CLI: [Installation Guide](https://diesel.rs/guides/getting-started.html)

We use PostgreSQL as our database in this tutorial. You’re free to use whatever you want, but this tutorial is geared
We use PostgreSQL as our database and Diesel as our ORM in this tutorial. You’re free to use whatever you want, but this tutorial is geared
towards PostgreSQL for the sake of simplicity. We use the following database configuration and tools:

### PostgreSQL Installation
[PostgreSQL](https://www.postgresql.org/download/)
1. `brew install libpq` ([this is a postgres C API library](https://formulae.brew.sh/formula/libpq)). Also perform all export commands post-installation
2. `brew install postgres`
3. `pg_ctl -D /opt/homebrew/var/postgres start` or `brew services start postgresql`
4. `/opt/homebrew/bin/createuser -s postgres`
5. Ensure you're able to do: `psql postgres`
6. `cargo install diesel_cli --no-default-features --features postgres`
7. Make sure that you're in the DB folder (run `cd src/db/postgres` from base directory), run `diesel migration run --database-url postgresql://localhost/postgres`
a. If for some reason this database is already being used, try a different db. e.g.
`DATABASE_URL=postgres://postgres@localhost:5432/indexer_v2 diesel database reset`

- We will use a database hosted on `localhost` on the port `5432`, which should be the default.
- When you create your username, keep track of it and the password you use for it.
- You can view a tutorial for installing PostgreSQL and
psql [here](https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-22-04-quickstart)
tool to set up your database more quickly.
- To easily view your database data, consider using a GUI like [DBeaver](https://dbeaver.io/)
*recommended*, [pgAdmin](https://www.pgadmin.org/), or [Postico](https://eggerapps.at/postico2/).

Explaining how to create a database is beyond the scope of this tutorial. If you are not sure how to do it, consider
checking out tutorials on how to create a database with the `psql` tool.

## Setting up your environment

Make sure to start the `postgresql` service:
Expand Down

0 comments on commit 3db7939

Please sign in to comment.