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

I had this problem too - and running that script required a bit of coaching from ask.discourse.com as it isn’t super easy for less expert sysadmins!

Here is a summary for others:


For anyone hitting this on the standard docker install, here’s how to actually run the script above.

Get a shell and open psql.

  • Single container:

    cd /var/discourse
    ./launcher start app   ## Only needed if you've had a failed rebuild already
    ./launcher enter app
    su -c 'psql discourse' postgres
    
    
  • Two-container setup:

    cd /var/discourse
    ./launcher enter data
    su -c 'psql discourse' postgres
    
    

You should see a discourse=# prompt. If unsure, run \conninfo.

Run the script.

Paste the whole DO $$ ... $$; block from nat’s post above at the prompt and press Enter. A successful run prints notices like:

NOTICE:  Renamed resenha_rooms to voice_rooms
NOTICE:  Renamed resenha_room_memberships to voice_room_memberships
...

If instead it raises an exception (e.g. “Both Resenha and Voice tables exist. Nothing was changed.”), stop and paste the message back here — the script is deliberately safe and changes nothing in that case.

Exit and rebuild.

\q
exit

then back on the host:

./launcher rebuild app          # single container
./launcher rebuild web_only     # two-container (can also do via bootstrap of course)

You may need two rebuilds — the first finishes the half-applied migration state, the second completes cleanly.