01/24/2023, 5:08 PM
Hey team, When self-hosting Infracost's Cloud Pricing API, I encounter various errors about tables not existing in the
database. Normally, I’d expect Infracost to populate the database, but that doesn’t seem to be the case. Here’s one example when clicking “Show stats” in the web app:
postgres   | 2023-01-24 17:05:29.016 UTC [53] ERROR:  relation "stats" does not exist at character 283
postgres   | 2023-01-24 17:05:29.016 UTC [53] STATEMENT:  
postgres   |        SELECT
postgres   |          stats.created_at,
postgres   |          stats.prices_last_successfully_updated_at,
postgres   |          stats.prices_last_update_successful,
postgres   |          stats.total_runs,
postgres   |          stats.ci_runs,
postgres   |          stats.non_ci_runs,
postgres   |          (SELECT COUNT(installs.install_id) FROM installs) as non_ci_installs
postgres   |        FROM stats as stats
postgres   |        LIMIT 1
postgres   |        
infracost  | {"level":50,"time":1674580019891,"pid":19,"hostname":"dafa22249a36","msg":"GraphQL encountered errors:\n[{\"message\":\"relation \\\"products\\\" does not exist\",\"locations\":[{\"line\":3,\"column\":4}],\"path\":[\"products\"]}]"}
postgres   | 2023-01-24 17:06:59.847 UTC [69] ERROR:  relation "products" does not exist at character 15
postgres   | [statement redacted]
There are similar errors when running
infracost breakdown --path .
error: relation "installs" does not exist
, or that GraphQL encountered errors saying
relation "products" does not exist
requests to my API succeed as normal, but all my breakdowns say everything is $0, though that's probably because of the above issues. Any advice?


01/24/2023, 5:13 PM
Hi Erik, it depends on how you are deploying but there is a job that should initialize the db tables needed. For example step 5 in the docker compose instructions has you run
docker-compose run init_job
which initializes the db schema and downloads the pricing data


01/24/2023, 5:14 PM
Ahh, that just occurred to me as well, I might have spoken too soon
Yup, I skipped over Step 5 in the deployment steps. Sorry!