Heads up: Use ApplicationRecord base for your models

Heads up!

Ivan merged my patch that changes behavior of how orchestration is
logged. Previously it was logging everything into sql logger which is
usually turned off by default as it is flooding logs. Since
orchestration logs are very important I made a change which made
possible to redirect orchestration logs into "app" logger.

https://github.com/theforeman/foreman/commit/4deab2f313841e4283469ce9faafc0cdf1775720

The patch which was merged introduces new class ApplicationRecord
(inherits from ActiveRecord::Base) which is something that will be in
Rails 5 anyway and adds Foreman custom logger so all our logs from
ActiveRecord objects goes into app logger but all SQL related stuff
goes through ActiveSupport notifications into logger called sql. This
is what we want.

So new models must inherit now from ApplicationRecord rather than from
ActiveRecord::Base. I filed a PR into Katello and Discovery, please
update your plugins. It's not a breaking change so if you keep using
ActiveRecord::Base plugin will usually work just fine but logs will
keep ending up in the wrong logger making debugging more difficult.

Unit tests passed locally and on jenkins
(http://ci.theforeman.org/job/test_develop/2772/) but Ori reported
this error after pull:

PG::UndefinedTable: ERROR: relation "application_records" does not exist

It looks like some gems are not compatible with ApplicationRecord,
looks like it must be some old or custom gem or Foreman plugin that
has some kind of dependency. ApplicationRecord is an abstract class,
it must be treatened differently. More details here:

Report here if you encounter issues after git pull, bundle update and
migration. In that case I recommend cleaning RVM environment and
installing just the gems which are required by Foreman. You need to
identify which gem is breaking it, unfortunately this is a bit hard to
track down.

··· -- Later, Lukas @lzap Zapletal

> Heads up!
>
> PG::UndefinedTable: ERROR: relation "application_records" does not exist

This error appears to show up when Rails devel environment is reloaded
on change. We are tracking this down, but be careful until we find
this.

··· -- Later, Lukas @lzap Zapletal

> > Heads up!
> >
> > PG::UndefinedTable: ERROR: relation "application_records" does not exist
>
> This error appears to show up when Rails devel environment is reloaded
> on change. We are tracking this down, but be careful until we find
> this.

https://github.com/theforeman/foreman/pull/4454 is merged, I take it
this is now fixed on develop

··· On 04/12, Lukas Zapletal wrote:


Later,
Lukas @lzap Zapletal


You received this message because you are subscribed to the Google Groups “foreman-dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Daniel Lobato Garcia

@dLobatog
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato