bullet-train-pro / bullet_train-audit_logs

MIT License
1 stars 1 forks source link

PG::UndefinedTable: ERROR: relation "versions" does not exist #7

Closed jagthedrummer closed 1 hour ago

jagthedrummer commented 1 hour ago

In a new BT app I added this gem via the GitHub repo and then did this:

bin/rails generate super_scaffold Project Team name:text_field
bin/rails generate super_scaffold:audit_log Project Team name:text_field
bin/rails db:migrate

The migration for audit logs ran, but then when we try to generate an ERD it throws this error:

NoMethodError: undefined method `name' for nil (NoMethodError)

          (mapping[relationship.destination.name] ||= []) << relationship
                                           ^^^^^
/Users/jgreen/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rails-erd-1.7.2/lib/rails_erd/domain.rb:108:in `block (2 levels) in relationships_mapping'
/Users/jgreen/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rails-erd-1.7.2/lib/rails_erd/domain.rb:106:in `each'
/Users/jgreen/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rails-erd-1.7.2/lib/rails_erd/domain.rb:106:in `block in relationships_mapping'
<internal:kernel>:90:in `tap'

Since the migration ran I tried to use the app, but when I go to create a new Project or view the activity stream of an existing one I get this error, sadly with no backtrace:

ActiveRecord::StatementInvalid in Account::ProjectsController#activity
PG::UndefinedTable: ERROR: relation "versions" does not exist LINE 10: WHERE a.attrelid = '"versions"'::regclass ^
jagthedrummer commented 1 hour ago

This seems like a version of this problem: https://github.com/paper-trail-gem/paper_trail/issues/1464

jagthedrummer commented 1 hour ago

If I change the Activity::Version model from starting like this:

class Activity::Version < PaperTrail::Version

to starting like this:

class Activity::Version < ActiveRecord::Base
  include PaperTrail::VersionConcern

then things start working.