How to troubleshoot database errors in an outdated plugin?

I’m new to Discourse plugin development, and to start off I’m trying to update this quiz plugin to work with the latest version of Discourse.

If it’s not too much trouble, I could use some help understanding how to troubleshoot this error that comes up whenever I try to make or view a topic while the plugin is enabled:


Job exception: PG::UndefinedTable: ERROR:  relation "quizzes" does not exist
LINE 9:  WHERE a.attrelid = '"quizzes"'::regclass


rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:110:in `exec'
rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:110:in `async_exec'
activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `block (2 levels) in query'
activesupport-7.0.8/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
activesupport-7.0.8/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:18:in `block in query'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

Are there any common problems I should look for that might be why the relation doesn’t exist? Would those problems typically be found in in /db?

In case it’s relevant: I’m using the Docker dev environment on Linux as described in this guide and you can see what I’ve done so far here.

Looks like you haven’t run migrations

You need an extra environment variable to run them for plugins, see:


Thanks for the quick reply! I just noticed d/migrate, which seemed to fix the issue after I ran it. How does that compare to LOAD_PLUGINS=1 RAILS_ENV=test rake db:migrate?

d/migrate is a docker script wrapper.

the command I shared is the real rails command that is run.

alternatively, you can enter the running container and run the rails command.

(but yes, you don’t need to target the test environment!)

Sounds good! Thanks for the help.

I opened up d/migrate and saw that it has everything from the command you shared except LOAD_PLUGINS=1. I’m not sure why it worked without that, but that’s all fine by me.


Good man!

Always good to lift the covers! A lot of people simply don’t read the source code and that is often more helpful than you realise!

Yes that’s an interesting distinction - wonder if its only necessary when doing this for the test environment :thinking:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.