Skip to content

PG::UndefinedTable: ERROR: relation "trends" does not exist #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fadamo opened this issue Feb 25, 2021 · 14 comments
Open

PG::UndefinedTable: ERROR: relation "trends" does not exist #29

fadamo opened this issue Feb 25, 2021 · 14 comments

Comments

@fadamo
Copy link

fadamo commented Feb 25, 2021

Hello,

we have migrated Katello 3.7.1 to 3.18 (-> foreman 2.3.2).
We were using Trends, so I installed tfm-rubygem-foreman_statistics.

After services' restart the Trends menu got visible but clicking on it appeared an error about old data.
So I ran "foreman-rake purge:trends".

Now it seems I don't have the trends table anymore, running foreman_statistics:trends:counter I got:

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

How can I recreate the missing tables ?

Thanks
Bye

@ezr-ondrej
Copy link
Member

Hi @fadamo,

That's unfortunate, foreman-rake purge:trends remove all the trends, so you've lost historical data, unless you've got backup of them.

But running foreman-rake db:migrate with plugin installed should recreate the plugin tables and allow you use the plugin again.

Let me know if that works :)

Ondrej

@fadamo
Copy link
Author

fadamo commented Feb 26, 2021 via email

@fadamo
Copy link
Author

fadamo commented Feb 26, 2021

Hi,

reading https://github.com/theforeman/foreman_statistics/pull/22/files/34dd4d67c8c88aa40b57052392978088e8d0f40f

I did the following:

[root@XXXXXXXXXX:~]# diff -Naur /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/index.html.erb{,.orig}
--- /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/index.html.erb 2021-02-26 14:48:05.066827757+0100
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/index.html.erb.orig 2020-09-30 12:45:48.000000000 +0200
@@ -1,6 +1,6 @@
<%= javascript 'charts' %>
<% title ("Trends") %>
-<% title_actions new_link(
("Add Trend Counter"), engine: foreman_statistics),
+<% title_actions new_link(_("Add Trend Counter")),
documentation_button('4.1.3Trends') %>

[root@XXXXXXXXXX:~]# diff -Naur /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/welcome.html.erb{,.orig}
--- /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/welcome.html.erb 2021-02-26 14:49:06.964913337+0100
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_statistics-1.0.0/app/views/foreman_statistics/trends/welcome.html.erb.orig 2020-09-30 12:45:48.000000000 +0200
@@ -7,6 +7,6 @@

<%= _("Trends in Foreman allow you to track changes in your infrastructure over time. It allows you to track both Foreman related information and to any fact. The Trend pages give a graph of how the number of hosts with that value have changed over time, and list the current hosts.") %>

<%= link_to _('Learn more about this in the documentation.'), documentation_url("4.1.3Trends")%>

- <%= new_link(_("Add Trend Counter"), { engine: foreman_statistics }, :class => 'btn-lg') %> + <%= new_link(_("Add Trend Counter"), :class => 'btn-lg') %>

Now I reach the Trends page but when I click "add" I wait forever on a blank page.

Bye

@ezr-ondrej
Copy link
Member

Yeah this is in 2.4 only, so if you apply it manually, it should start working for you.

@ezr-ondrej
Copy link
Member

Do you see any js error?

@fadamo
Copy link
Author

fadamo commented Feb 27, 2021

Do you see any js error?

What I see is a blank frame and the tab loading for a long time. Using Dev Tools I see I receive 30MB (!) of data, with the "new" page large about 1,2MB but apparently conpletely empty.

If you want I can share a screenshot.

Thanks a lot.

@ezr-ondrej
Copy link
Member

Can you try to enter the url <foreman_host>/foreman_statistics/trends/new manually and if that works verify where the Add Trend Counter button is redirecting you. 🤔

@fadamo
Copy link
Author

fadamo commented Feb 27, 2021

Can you try to enter the url <foreman_host>/foreman_statistics/trends/new manually and if that works verify where the Add Trend Counter button is redirecting you. 🤔

It doesn't work.
The button links exactly https://xxxxxxxxxxxxxxx/foreman_statistics/trends/new.

@fadamo
Copy link
Author

fadamo commented Feb 27, 2021

trends
trends2

I hope here you can see something interesting.

@ezr-ondrej
Copy link
Member

It all seem normal 🤔
Did you reassign the permissions to your user? the permissions were removed and recreated, so there can be something weird happening, unless you're admin ofc... You might try to upgrade to foreman 2.4, but apart of that I've got no idea. It all seems to be working, but the form just won't show up for some reason....

@fadamo
Copy link
Author

fadamo commented Mar 1, 2021

I'm an Administrator.
Ok, thank you very much for your time.

@fraenki
Copy link

fraenki commented May 13, 2024

PG::UndefinedTable: ERROR: relation "trends" does not exist
How can I recreate the missing tables ?

But running foreman-rake db:migrate with plugin installed should recreate the plugin tables and allow you use the plugin again.

I ran into a similar issue on Foreman 3.10.0 and foreman_statistics-2.1.0, but in my case running db:migrate did not recreate the plugin tables. Is this still expected to work like this?

@ezr-ondrej
Copy link
Member

ezr-ondrej commented May 13, 2024

It is expected to work, but I doubt it's been frequently tested, so it might go wrong. Did you see any errors?

@fraenki
Copy link

fraenki commented May 13, 2024

No, unfortunately no errors. Is there a manual way to rerun the db seed for this plugin? Maybe using foreman console?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants