Migrationsfehler mit question2answer.rb

Hallo,

ich versuche, das Import-Skript question2answer.rb zu verwenden, um meine Seite auf die Discourse-Plattform zu migrieren. Dabei trete ich jedoch während des Migrationsprozesses auf den folgenden Fehler.

Wie kann ich ihn beheben? :thinking: Ich verwende den Standard-Docker-Container auf einer sauberen Ubuntu 18.04.

importing users

**Traceback** (most recent call last):

9: from script/import_scripts/question2answer.rb:560:in `\u0026lt;main\u0026gt;'\n\n    8: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'\n\n    7: from script/import_scripts/question2answer.rb:71:in `execute'\n\n    6: from script/import_scripts/question2answer.rb:85:in `import_users'\n\n    5: from script/import_scripts/question2answer.rb:555:in `mysql_query'\n\n    4: from /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/mysql2.rb:22:in `query'\n\n    3: from /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `query'\n\n    2: from /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `handle_interrupt'\n\n    1: from /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `block in query'\n\n    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `_query': **Table 'primary_db.users' doesn't exist (** **Mysql2::Error** **)**

The users table that it’s looking for does not exist. Do you see a table called “users”? Do you have the right database?

2 „Gefällt mir“

I believe that I have the right database as I finished importing the database (on Discourse server) using

mysql -uroot -p -e 'CREATE DATABASE q2a' 

mysql -uroot -p q2a < q2a_dump.sql

I was able to back up my new database using

mysqldump -u username -p database_to_backup > backup_name.sql

and I downloaded it on my computer to verify that I have the proper database.

I have a table called qa_users

That’s the default. Did you change the db_prefix to “primary_dB” for some reason?

It was already included in the importer script as follows.

  # CHANGE THESE BEFORE RUNNING THE IMPORTER

  DB_HOST ||= ENV['DB_HOST'] || "localhost"
  DB_NAME ||= ENV['DB_NAME']
  DB_PW ||= ENV['DB_PW']
  DB_USER ||= ENV['DB_USER']
  TIMEZONE ||= ENV['TIMEZONE'] || "America/Los_Angeles"
  TABLE_PREFIX ||= ENV['TABLE_PREFIX'] || "qa_"
  MAIN_APP_DB_NAME = "primary_db"

So I didn’t change MAIN_APP_DB_NAME part as I am not familiar with that.

Did you set those environment variables? DB_NAME TABLE_PREFIX and so on?

I set all environment variables that I quoted above.

What did you set TABLE_PREFIX to?

export TABLE_PREFIX=“qa_”

Sorry. I’m in my logins and didn’t read the code carefully.

I’m pretty sure that I wrote that script, but I didn’t see that main all stuff down in the query; I’m sure I didn’t write that.

You’ll need to edit the script to have it use the database and prefix that you set in the environment variables.

What should I do about this one?

You’ll need to rewrite all of the dB queries.

I am sorry, Jay. I am not quite sure what you mean by that? Could you please give me some pointers here? I hope that you don’t mean by rewriting the importer script of question2answer.

Thanks

Not the whole script, just the database queries, and really just the FROM part. If you have a budget I can fix it for you.

2 „Gefällt mir“

I don’t have much budget but I would like to import small data from my old forum.

What do you have in mind?

Send an email to support@literatecomputing.com.

If I can log in remotely to the machine where you’re running the import it’ll help, as I’ll be able to see whether it works without sending it to you, having you import, tell me what’s wrong, and trying again.

2 „Gefällt mir“

It seems the question2answer importer was written for a case where there is an additional set of tables in the database for another app that was integrated with it. That is what the MAIN_APP_DB_NAME refers to.

We have done an import for a standalone q2a site recently and we have a modified version of the script which does not depend on this extra database. @RGJ was going to clean it up and submit it back in the next few weeks.

4 „Gefällt mir“

[Hier](https://gist.github.com/[Communiteq](https://www.communiteq.com) (ehemals DiscourseHosting)/769eff2014d5482f0ab776de03dc3349) ist ein Gist unseres modifizierten Importers, damit Sie nicht warten müssen, bis ich ihn bereinigt habe. Der Code ist bereits ziemlich in Ordnung.

  • Abhängigkeit von dieser anderen mysteriösen Datenbank entfernen, die wahrscheinlich etwas Maßgeschneidertes ist
  • Kommentare importieren
  • Beste Antwort importieren
5 „Gefällt mir“

Aw nice, thanks for that :beers:

1 „Gefällt mir“

Beim jüngsten Versuch, kleine Datenmengen von meinem alten Forum zu migrieren, trat beim Verwenden des [angepassten Importerskripts](https://gist.github.com/[Communiteq](https://www.communiteq.com) (ehemals DiscourseHosting)/769eff2014d5482f0ab776de03dc3349) von @RGJ folgender Fehler auf:

Lade bestehende Gruppen...

Lade bestehende Benutzer...

Lade bestehende Kategorien...

Lade bestehende Beiträge...

Lade bestehende Themen...

Importiere Benutzer

**Traceback** (letzte Aufrufkette):

11: von script/import_scripts/question2answer.rb:601:in `&lt;main&gt;'

10: von /var/www/discourse/script/import_scripts/base.rb:47:in `perform'

9: von script/import_scripts/question2answer.rb:70:in `execute'

8: von script/import_scripts/question2answer.rb:89:in `import_users'

7: von /var/www/discourse/script/import_scripts/base.rb:881:in `batches'

6: von /var/www/discourse/script/import_scripts/base.rb:881:in `loop'

5: von /var/www/discourse/script/import_scripts/base.rb:882:in `block in batches'

4: von script/import_scripts/question2answer.rb:106:in `block in import_users'

3: von /var/www/discourse/script/import_scripts/base.rb:247:in `create_users'

2: von /var/www/discourse/script/import_scripts/base.rb:247:in `each'

1: von /var/www/discourse/script/import_scripts/base.rb:278:in `block in create_users'

/var/www/discourse/script/import_scripts/base.rb:866:in `print_status': **undefinierte Methode `to_f' für #&lt;Mysql2::Result:0x000056370b7c1f80&gt; (** **NoMethodError** **)**

**Meinten Sie: to_s**

**to_a**

**to_h**

Ich frage mich, was diesen Fehler verursacht? :confused: