从一个Discourse实例导入类别到另一个实例时出错

您好,Discourse 团队!

我在尝试将分类从暂存环境导出到生产环境时遇到了一个错误。为了方便起见,我们在暂存环境中有很多主题希望发布到生产环境中,而复制粘贴会花费很长时间。

这是我在运行 discourse import_category category-export-2022-02-14-042606.json(基于此教程)后遇到的错误:

Starting import from category-export-2022-02-14-042606.json...
Importing users...
Importing groups...
bundler: failed to load command: script/discourse (script/discourse)
Traceback (most recent call last):
	42: from /usr/local/bin/bundle:25:in `<main>'
	41: from /usr/local/bin/bundle:25:in `load'
	40: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:36:in `<top (required)>'
	39: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	38: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:48:in `block in <top (required)>'
	37: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:25:in `start'
	36: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	35: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:31:in `dispatch'
	34: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	33: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	32: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	31: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:484:in `exec'
	30: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:23:in `run'
	29: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
	28: from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `load'
	27: from script/discourse:290:in `<top (required)>'
	26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	22: from script/discourse:243:in `import_category'
	21: from /var/www/discourse/lib/import_export.rb:15:in `import'
	20: from /var/www/discourse/lib/import_export/importer.rb:25:in `perform'
	19: from /var/www/discourse/lib/import_export/importer.rb:61:in `import_groups'
	18: from /var/www/discourse/lib/import_export/importer.rb:61:in `each'
	17: from /var/www/discourse/lib/import_export/importer.rb:65:in `block in import_groups'
	16: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/persistence.rb:55:in `create!'
	15: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/suppressor.rb:48:in `save!'
	14: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/transactions.rb:302:in `save!'
	13: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
	12: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
	11: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
	10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
	 9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
	 8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
	 7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
	 6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
	 5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
	 4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
	 3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
	 2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/transactions.rb:302:in `block in save!'
	 1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/validations.rb:53:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/validations.rb:80:in `raise_validation_error': Validation failed: You cannot allow membership requests for a group without any owners. (ActiveRecord::RecordInvalid)

我只想导出分类,所以我不太确定它为什么会抱怨组。

非常感谢任何帮助!

祝好,
Tim

只是顶一下,看看是否有人遇到过这个问题?

我认为该脚本试图导入所有内容。

您可以尝试从 JSON 中删除该组,或修改脚本以跳过该组。

您好 @pfaffman

感谢您的回复!

您说的“所有内容”是什么意思?我会尝试一下,并将组从 json 中编辑掉。我以为教程只针对类别/主题,所以没想到它会给我更多内容。

测试后我会汇报!

这是一个滑坡。没有用户就无法创建主题,然后以此类推。