Foreman 1.9: ERROR: column hosts.last_freshcheck does not exist

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 21, 2015

Follow me on Twitter as @mattiasgeniar

If you’ve recently upgraded your Foreman 1.8 setup to 1.9, you may see the following error in your dashboard when navigating to a particular host.

# Oops, we're sorry but something went wrong

PGError: ERROR: column hosts.last_freshcheck does not exist LINE 1: ..."name" AS t1_r1, "hosts"."last_compile" AS t1_r2, "hosts"."l... ^ : SELECT "reports"."id" AS t0_r0, "reports"."host_id" AS t0_r1, "reports"."reported_at" AS t0_r2, ...

The upgrade steps will tell you to execute the following database migrations:

$ cd /usr/share/foreman
$ foreman-rake db:migrate
$ foreman-rake db:seed

You can check if the migrations were all executed correctly, by running the following command.

$ cd /usr/share/foreman
$ foreman-rake db:migrate:status
...
   up     20150618093433  Remove unused fields from hosts
   up     20150622090115  Change reported at
   up     20150714140850  Remove new from compute attributes

If the output shows “up”, it means that particular database migration script is up-to-date and was executed. Nothing to do here.

The error concerning the hosts.last_freshcheck column is a result of a cleanup issue where obsoleted columns have been removed. The resulting code is found in pull request 2471.

If your database migrations are all completed and you still see the error, restart your Apache server. The Ruby/Passengers processes keep a cache in memory of the database structure, that isn’t refreshed when running the foreman-rake db:migrate commands.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.