Skip to content

Commit c1b4263

Browse files
authored
Merge pull request #1748 from IntersectMBO/1747-postgres-docs
Add better docs on setting up postgresql db
2 parents ec38417 + c2c3ec4 commit c1b4263

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

doc/building-running.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,48 @@ make install
5555

5656
```
5757

58-
- with cabal:
58+
### Clone repository
5959

60-
```
60+
Start by cloning the `cardano-db-sync` repository from GitHub.
61+
```sh
6162
git clone https://github.com/IntersectMBO/cardano-db-sync
63+
```
64+
65+
Navigate into the cloned repository directory.
66+
```sh
6267
cd cardano-db-sync
63-
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --createdb
68+
```
69+
70+
**Checkout and Create Branch**: Check out the latest official tag and create a new branch based on that tag. Replace `<latest-official-tag>` with the specific tag you want to use.
71+
```sh
6472
git checkout <latest-official-tag> -b tag-<latest-official-tag>
73+
```
74+
75+
## Using Cabal
76+
77+
**Database Setup**: Set up the PostgreSQL database using the provided script with the configuration in `config/pgpass-mainnet`.
78+
```sh
79+
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --createdb
80+
```
6581

82+
**Build the Project**: Use Cabal to build the `cardano-db-sync` project.
83+
```sh
6684
cabal build cardano-db-sync
85+
```
86+
87+
**Run the Sync Node**:
88+
- Ensure the `config/mainnet-config.yaml` file is correctly specified.
89+
- Use the appropriate socket path for the Cardano node.
90+
- Define the directories for storing ledger state and schema files.
91+
```sh
6792
PGPASSFILE=config/pgpass-mainnet cabal run cardano-db-sync -- \
6893
--config config/mainnet-config.yaml \
6994
--socket-path ../cardano-node/state-node-mainnet/node.socket \
7095
--state-dir ledger-state/mainnet \
7196
--schema-dir schema/
7297
```
7398

74-
to find `cardano-db-sync` executable location use:
99+
If building locally, to find `cardano-db-sync` executable location use:
75100

76101
```
77102
find . -name cardano-db-sync -executable -type f
@@ -82,14 +107,23 @@ On macOS `brew install postgresl [email protected]` and extend PKG_CONFIG_PATH with
82107
`PKG_CONFIG_PATH=/usr/local/opt/postgresql/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig cabal build all`
83108
when running cabal build
84109

85-
- with nix:
110+
## Using Nix:
86111

87-
```
88-
git clone https://github.com/IntersectMBO/cardano-db-sync
89-
cd cardano-db-sync
90-
git checkout <latest-official-tag> -b tag-<latest-official-tag>
112+
**Build the Project**: Build the cardano-db-sync project using Nix
113+
```sh
91114
nix build -v .#cardano-db-sync -o db-sync-node
115+
```
116+
117+
Set up the PostgreSQL database using the provided script with the configuration in `config/pgpass-mainnet`
118+
```sh
92119
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --createdb
120+
```
121+
122+
**Run the Sync Node**:
123+
- Ensure the `config/mainnet-config.yaml` file is correctly specified.
124+
- Use the appropriate socket path for the Cardano node.
125+
- Define the directories for storing ledger state and schema files.
126+
```sh
93127
PGPASSFILE=config/pgpass-mainnet db-sync-node/bin/cardano-db-sync \
94128
--config config/mainnet-config.yaml \
95129
--socket-path ../cardano-node/state-node-mainnet/node.socket \

0 commit comments

Comments
 (0)