Freika / dawarich

Self-hosted alternative to Google Location History (Google Maps Timeline)
https://dawarich.app
GNU Affero General Public License v3.0
2.43k stars 60 forks source link

`UndefinedTable` error when trying to load suggested visits #263

Open tchan09 opened 2 months ago

tchan09 commented 2 months ago

Describe the bug On the beta visits page, clicking on the suggested button triggers an ActiveRecord error:

Showing /var/app/app/views/visits/_modal.html.erb where line #20 raised:

PG::UndefinedTable: ERROR:  relation "place_visits" does not exist
LINE 10:  WHERE a.attrelid = '"place_visits"'::regclass
                             ^

Trace of template inclusion: #<ActionView::Template app/views/visits/_visit.html.erb locals=["visit"]>, #<ActionView::Template app/views/visits/index.html.erb locals=[]>

Rails.root: /var/app

Version 0.14.1 via docker

To Reproduce Steps to reproduce the behavior:

  1. Go to Visits page from the navigation tab
  2. Click on the 'Suggested' button
  3. See error

Expected behavior I expect to suggested visits.

Logs From dawarich_app:

17:17:46 web.1  | D, [2024-09-20T17:17:46.542368 #86] DEBUG -- :   User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
17:17:46 web.1  | D, [2024-09-20T17:17:46.542731 #86] DEBUG -- :   ↳ app/controllers/application_controller.rb:11:in `unread_notifications'
17:17:46 web.1  | D, [2024-09-20T17:17:46.544550 #86] DEBUG -- :   Visit Load (0.7ms)  SELECT "visits".* FROM "visits" WHERE "visits"."user_id" = $1 AND "visits"."status" = $2 ORDER BY "visits"."started_at" ASC  [["user_id", 1], ["status", 0]]
17:17:46 web.1  | D, [2024-09-20T17:17:46.544824 #86] DEBUG -- :   ↳ app/controllers/visits_controller.rb:15:in `group_by'
17:17:46 web.1  | D, [2024-09-20T17:17:46.548022 #86] DEBUG -- :   Visit Count (0.2ms)  SELECT COUNT(*) FROM "visits" WHERE "visits"."user_id" = $1 AND "visits"."status" = $2  [["user_id", 1], ["status", 0]]
17:17:46 web.1  | D, [2024-09-20T17:17:46.548209 #86] DEBUG -- :   ↳ app/controllers/visits_controller.rb:18:in `index'
17:17:46 web.1  | D, [2024-09-20T17:17:46.548603 #86] DEBUG -- :   Rendering layout layouts/application.html.erb
17:17:46 web.1  | D, [2024-09-20T17:17:46.548630 #86] DEBUG -- :   Rendering visits/index.html.erb within layouts/application
17:17:46 web.1  | I, [2024-09-20T17:17:46.551571 #86]  INFO -- : {"method":"GET","path":"/visits","format":"html","controller":"VisitsController","action":"index","status":500,"allocations":9653,"duration":11.15,"view":0.0,"db":1.77}
17:17:46 web.1  | F, [2024-09-20T17:17:46.552939 #86] FATAL -- :   
17:17:46 web.1  | ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "place_visits" does not exist
17:17:46 web.1  | LINE 10:  WHERE a.attrelid = '"place_visits"'::regclass
17:17:46 web.1  |                              ^
17:17:46 web.1  | ):
17:17:46 web.1  | 
17:17:46 web.1  | Causes:
17:17:46 web.1  | ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "place_visits" does not exist
17:17:46 web.1  | LINE 10:  WHERE a.attrelid = '"place_visits"'::regclass
17:17:46 web.1  |                              ^
17:17:46 web.1  | )
17:17:46 web.1  | PG::UndefinedTable (ERROR:  relation "place_visits" does not exist
17:17:46 web.1  | LINE 10:  WHERE a.attrelid = '"place_visits"'::regclass
17:17:46 web.1  |                              ^
17:17:46 web.1  | )
17:17:46 web.1  |     17:              data-api_key="<%= current_user.api_key %>"
17:17:46 web.1  |     18:              data-controller="visit-modal-places"
17:17:46 web.1  |     19:              data-id="<%= visit.id %>">
17:17:46 web.1  |     20:           <% if visit.suggested_places.any? %>
17:17:46 web.1  |     21:             <%= select_tag :place_id,
17:17:46 web.1  |     22:                 options_for_select(
17:17:46 web.1  |     23:                   visit.suggested_places.map { |place| [place.name, place.id] },
17:17:46 web.1  |   
17:17:46 web.1  | D, [2024-09-20T17:17:46.553518 #86] DEBUG -- :   Rendering layout vendor/bundle/ruby/3.3.0/gems/actionpack-7.2.1/lib/action_dispatch/middleware/templates/rescues/layout.erb
17:17:46 web.1  | D, [2024-09-20T17:17:46.553544 #86] DEBUG -- :   Rendering vendor/bundle/ruby/3.3.0/gems/actionpack-7.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout
17:17:46 web.1  | D, [2024-09-20T17:17:46.555291 #86] DEBUG -- :   Rendering vendor/bundle/ruby/3.3.0/gems/actionpack-7.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
sakowicz commented 4 days ago

Facing the same issue:

ActiveRecord::StatementInvalid in Visits#index
Showing /var/app/app/views/visits/_modal.html.erb where line #20 raised:

PG::UndefinedTable: ERROR:  relation "place_visits" does not exist
LINE 10:  WHERE a.attrelid = '"place_visits"'::regclass
                             ^
Trace of template inclusion: #<ActionView::Template app/views/visits/_visit.html.erb locals=["visit"]>, #<ActionView::Template app/views/visits/index.html.erb locals=[]>

Rails.root: /var/app