PG::UndefinedTable: ERROR: la relazione "voice_rooms" non esiste

Proseguendo la discussione da Fatal: could not read Username for 'https://github.com':

I problemi con GitHub sono ormai risolti, credo, ma l’aggiornamento fallisce. Questo è il primo incidente:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError) 
PG::UndefinedTable: ERROR:  relation "voice_rooms" does not exist

Sto usando 2 container (ho eseguito anche data, senza errori) e sono all’ultima versione.

Qualche idea?

PG::UndefinedTable: ERROR: relation "voice_rooms" does not exist compare perché le migrazioni per il nuovo plugin voice incluso nel core non sono ancora state eseguite.

C’era qualcosa sopra rake aborted!?

C’è… parecchia roba :laughing: Ma niente che mi abbia fatto pensare a qualcosa di familiare.

x86_64 arch detected.                                                                                                                                                 
Ensuring launcher is up to date                                                                                                                                       
Launcher is up-to-date                                                                                                                                                
Stopping old container                                                                                                                                                
+ /usr/bin/docker stop -t 600 web_only                                                                                                                                
web_only                                                                                                                                                              
2.0.20260812-0036: Pulling from discourse/base                                                                                                                        
Digest: sha256:837e8ed4b5916baa36856b842ad84fe262b6b1b5550701f8844b13cc7acad7a5                                                                                       
Status: Image is up to date for discourse/base:2.0.20260812-0036                                                                                                      
docker.io/discourse/base:2.0.20260812-0036                                                                                                                            
/usr/local/lib/ruby/gems/3.4.0/gems/pups-1.4.0/lib/pups.rb                                                                                                            
/usr/local/bin/pups --stdin                                                                                                                                           
I, [2026-09-03T08:55:23.418621 #1]  INFO -- : Reading from stdin                                                                                                      
I, [2026-09-03T08:55:23.453117 #1]  INFO -- : > thpoff echo "thpoff is installed!"                                                                                    
thpoff is installed!                                                                                                                                                  
I, [2026-09-03T08:55:23.461963 #1]  INFO -- : > /usr/local/bin/ruby -e 'if (ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com" && ENV["DISCOURSE_SKIP_EMAIL_SETUP"] !
= "1"); puts "Aborting! Mail is not configured!"; exit 1; end'                                                                                                        
I, [2026-09-03T08:55:23.608522 #1]  INFO -- : > /usr/local/bin/ruby -e 'if ENV["DISCOURSE_HOSTNAME"] == "discourse.example.com"; puts "Aborting! Domain is not configu
red!"; exit 1; end'                                                                                                                                                   
I, [2026-09-03T08:55:23.743204 #1]  INFO -- : > /usr/local/bin/ruby -e 'if (ENV["DISCOURSE_CDN_URL"] || "")[0..1] == "//"; puts "Aborting! CDN must have a protocol sp
cified

Sospetto che questo potrebbe essere correlato al fatto che le versioni di migrazione del precedente plugin resenha coincidano con quelle del nuovo plugin voice - probabilmente perché lo hai installato prima? Se non sei sicuro, puoi provare a eseguire questo comando nel tuo psql:

  SELECT version, name, direction, created_at, git_version
  FROM schema_migration_details
  WHERE version = '20241107000000'
  ORDER BY created_at;

Consulta resenha/db/migrate/20241107000000_create_resenha_rooms.rb at b87ca4e20d649ba6b7bdc4615b289c414854889e · xfalcox/resenha · GitHub e discourse/plugins/voice/db/migrate/20241107000000_create_voice_rooms.rb at main · discourse/discourse · GitHub

Dovrebbe esserci una correzione core per queste versioni di migrazione in conflitto… Immagino che dovrebbe interessare anche altri. Restate sintonizzati.

Sì, l’ho provato quando era ancora in fase iniziale, ma l’ho rimosso in seguito.

Ok - probabilmente si tratta di una migrazione di Resenha che si presumeva fosse stata eseguita, ma non lo è stata. Dato che lo stesso numero di versione della migrazione viene utilizzato nel core per la voce, il tentativo improvviso di aggiungere una colonna per voice_rooms non funzionerà, poiché il nome della tabella è ancora resenha_rooms.

Per ora puoi eseguire questo in psql:

DO
$$
  DECLARE
    has_resenha boolean;
    has_voice   boolean;
    table_pair  record;
  BEGIN
    SELECT EXISTS (SELECT 1
                   FROM unnest(ARRAY [
                     'resenha_rooms',
                     'resenha_room_memberships',
                     'resenha_sessions',
                     'resenha_co_presences',
                     'resenha_recordings',
                     'resenha_invites'
                     ]) AS names(name)
                   WHERE to_regclass(format('public.%I', name)) IS NOT NULL)
    INTO has_resenha;

    SELECT EXISTS (SELECT 1
                   FROM unnest(ARRAY [
                     'voice_rooms',
                     'voice_room_memberships',
                     'voice_sessions',
                     'voice_co_presences',
                     'voice_recordings',
                     'voice_invites'
                     ]) AS names(name)
                   WHERE to_regclass(format('public.%I', name)) IS NOT NULL)
    INTO has_voice;

    IF has_resenha AND has_voice THEN
      RAISE EXCEPTION
        'Both Resenha and Voice tables exist. Nothing was changed.';
    END IF;

    IF NOT has_resenha THEN
      IF to_regclass('public.voice_rooms') IS NOT NULL THEN
        RAISE NOTICE 'The tables have already been renamed.';
        RETURN;
      END IF;

      RAISE EXCEPTION
        'Neither resenha_rooms nor voice_rooms exists. Nothing was changed.';
    END IF;

    IF EXISTS (SELECT 1
               FROM schema_migrations
               WHERE version = '20260831162602') THEN
      RAISE EXCEPTION
        'The rename migration is already recorded. Nothing was changed.';
    END IF;

    FOR table_pair IN
      SELECT *
      FROM (VALUES ('resenha_rooms', 'voice_rooms', '20241107000000'),
                   ('resenha_room_memberships', 'voice_room_memberships',
                    '20241107000000'),
                   ('resenha_sessions', 'voice_sessions', '20260305165400'),
                   ('resenha_co_presences', 'voice_co_presences',
                    '20260305165401'),
                   ('resenha_recordings', 'voice_recordings',
                    '20260717172530'),
                   ('resenha_invites', 'voice_invites',
                    '20260813160047')) AS pairs(old_name, new_name, migration_version)
      LOOP
        IF EXISTS (SELECT 1
                   FROM schema_migrations
                   WHERE version = table_pair.migration_version) AND
           to_regclass(format('public.%I', table_pair.old_name)) IS NULL THEN
          RAISE EXCEPTION
            'Migration % is recorded, but table % is missing. Nothing was changed.',
            table_pair.migration_version,
            table_pair.old_name;
        END IF;

        IF to_regclass(format('public.%I', table_pair.old_name)) IS NOT NULL THEN
          EXECUTE format(
            'ALTER TABLE public.%I RENAME TO %I',
            table_pair.old_name,
            table_pair.new_name
                  );

          RAISE NOTICE 'Renamed % to %', table_pair.old_name, table_pair.new_name;
        END IF;
      END LOOP;
  END
$$;

Ecco cosa fa:

  1. verifica quali tabelle Resenha e Voice esistono.
  2. si rifiuta di continuare se entrambe esistono (non mi aspetto che ciò accada)
  3. verifica che le migrazioni registrate siano quelle attese
  4. rinomina le tabelle esistenti:
    • resenha_rooms → voice_rooms
    • resenha_room_memberships → voice_room_memberships
    • resenha_sessions → voice_sessions
    • resenha_co_presences → voice_co_presences
    • resenha_recordings → voice_recordings
    • resenha_invites → voice_invites
  5. questo aiuta a risolvere lo strano stato intermedio in cui ti trovi. la ricostruzione successiva dovrebbe riuscire

Dovrebbe consentire alle altre migrazioni del core di avere successo (renderà inattiva la migrazione core più recente relativa alla voce che esegue la rinomina).

Controllerò con il nostro team se dovremmo commitare questo come un task rake.

Grazie! Ha funzionato perfettamente.