diff --git a/chain/src/main.rs b/chain/src/main.rs index d616d5f..c417f85 100644 --- a/chain/src/main.rs +++ b/chain/src/main.rs @@ -7,6 +7,7 @@ use std::collections::BTreeMap; use std::sync::atomic::{self, AtomicBool}; use std::sync::Arc; +use anyhow::Context; use clap::Parser; use shared::error::{IntoMainError, MainError}; use shared::height::{BlockHeight, FollowingHeights}; @@ -46,6 +47,8 @@ async fn main() -> Result<(), MainError> { let app_state = AppState::new(database_url).into_db_error()?; + run_migrations(&app_state).await?; + let (last_block_height, commitment_tree, witness_map) = load_committed_state(&app_state).await?; @@ -102,6 +105,15 @@ fn must_exit_handle() -> Arc { handle } +async fn run_migrations(app_state: &AppState) -> Result<(), MainError> { + db_service::run_migrations( + app_state.get_db_connection().await.into_db_error()?, + ) + .await + .context("Failed to run db migrations") + .into_db_error() +} + async fn load_committed_state( app_state: &AppState, ) -> Result<(Option, CommitmentTree, WitnessMap), MainError> { diff --git a/docker-compose.yml b/docker-compose.yml index 35fcad3..33a580a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,9 +8,9 @@ services: POSTGRES_PASSWORD: password POSTGRES_USER: postgres PGUSER: postgres - POSTGRES_DB: indexer_local + POSTGRES_DB: masp_indexer_local healthcheck: - test: ["CMD-SHELL", "pg_isready", "-d", "indexer_local"] + test: ["CMD-SHELL", "pg_isready", "-d", "masp_indexer_local"] interval: 5s timeout: 10s retries: 5 @@ -24,23 +24,19 @@ services: ports: - 5000:5000 environment: - CARGO_ENV: development PORT: 5000 - DATABASE_URL: postgres://postgres:password@postgres:5432/indexer_local + DATABASE_URL: postgres://postgres:password@postgres:5432/masp_indexer_local depends_on: - crawler crawler: - image: namada-masp-crawler build: context: . dockerfile: chain/Dockerfile environment: - CARGO_ENV: development - TENDERMINT_URL: <> - CHECKSUMS_FILEPATH: <> + COMETBFT_URL: <> CHAIN_ID: <> - DATABASE_URL: postgres://postgres:password@postgres:5432/indexer_local + DATABASE_URL: postgres://postgres:password@postgres:5432/masp_indexer_local depends_on: postgres: condition: service_healthy diff --git a/webserver/Cargo.toml b/webserver/Cargo.toml index 5b5c7b9..fc75606 100644 --- a/webserver/Cargo.toml +++ b/webserver/Cargo.toml @@ -7,6 +7,7 @@ edition.workspace = true license.workspace = true readme.workspace = true version.workspace = true +build = "build.rs" [[bin]] name = "webserver"