This crate generates the PostgreSQL database schema used to store the rollups data: all of its inputs, notices, vouchers, reports and proofs.
If you want to run the PostgreSQL in your machine, you can run the following docker command:
docker run --rm --name test-postgres -e POSTGRES_PASSWORD=pw -p 5432:5432 -d postgres:13
The database migration requires diesel. Before installing diesel, you need to install the PostgreSQL development library. In Ubuntu, run the following command:
sudo apt install libpq-dev
Or if you are using MacOS:
brew install libpq &&
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
To install diesel run the following command:
cargo install diesel_cli --no-default-features --features postgres
Then, setup the environment variable DATABASE_URL referencing to the local PostgreSQL.
echo "export DATABASE_URL=postgres://postgres:pw@localhost:5432/postgres" > .env
Follow the commands below to perform the migration.
This procedure creates the tables in PostgreSQL and also generates the file src/schema.rs
.
diesel migration run
To modify the database schema, you should edit the files in the migration
dir.
For more details, please follow the instructions on the diesel site.
To run the automated tests, run the following command:
cargo test
If you want to fiddle with the database, you can populate it by running:
psql -h localhost -U postgres -d postgres -a -f util/populate.sql