Unclear how to set up the database
In the Quick start section, it says to run: source ./substrate-archive/scripts/up.sh, however the script no longer exists there. Is this still relevant? It seemed like a nice feature!
In general, it's unclear how to get the SQL database up and running:
- This example: https://github.com/paritytech/substrate-archive/wiki/1).-Requirements#example-setting-up-the-database seems to be the right place to provide steps on how to do this. Perhaps we could add instructions for different OS users. For me on macos when I run
createuser -s postgres, I get:createuser: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? - This example: https://github.com/paritytech/substrate-archive/wiki/1.)-Requirements#compiling-without-a-database alludes to the fact that you can still run the
substrate-archiveCLI without a database. But it's not so clear how. Where do I setSQLX_OFFLINE=truefor example? - Is there a way to run
node-template-archiveusing the CLI ?
If you can help me answer these questions I'll make a follow-up PR with the clarifications I think are needed. Thanks! 😃
Docs are pretty out of date. I suggest just using the included docker-compose to get a db up and running
- Run
docker-compose up -dto start postgres and pgadmin - Run
DATABASE_URL=postgres://postgres:123@localhost:6432/local_chain_db sqlx database createinsubstrate-archive/srcto create the database. - Run
DATABASE_URL=postgres://postgres:123@localhost:6432/local_chain_db sqlx migrate run insubstrate-archive/src` to create the tables. - Run
cargo run --release -- -c archive.tomlinbin/node-template-archive/to start indexing. Keep in mind to modify the archive.toml configs.
Yeah the docs can be confusing here, I think
This example: https://github.com/paritytech/substrate-archive/wiki/1).-Requirements#example-setting-up-the-database seems to be the right place to provide steps on how to do this. Perhaps we could add instructions for different OS users. For me on macos when I run createuser -s postgres, I get: createuser: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
I haven't had trouble with this on MacOS, this error generally occurs if the postgres server isn't running. how did you install postgres? (Postgres.app/homebrew/etc?)
This example: https://github.com/paritytech/substrate-archive/wiki/1.)-Requirements#compiling-without-a-database alludes to the fact that you can still run the substrate-archive CLI without a database. But it's not so clear how. Where do I set SQLX_OFFLINE=true for example?
Yeah I think this should have been more clear. SQLX_OFFLINE is not meant to enable archive to run without postgres/rocksdb but just to compile it for use in the context of something like CI. I.E SQLX_OFFLINE=true cargo check
What issue are you running into with node-template? It should just run along node-template-archive. It's easiest to bring up postgres/rabbitmq with docker-compose and then run node-template/archive combo after creating postgres user/database in docker-postgres. Thing to remember there would be to change the postgres port in archive.toml if you are running with a non-standard port in docker