从 Discuz! X 迁移到 Discourse


(Erick Guan) #1

脚本可以用来导入 Discuz! X 的数据,流程请参考:

该脚本仅测试过了 UTF-8 简体中文版 Discuz! X。

数据准备

应将 Discuz! X 升级至 3.x 版本。

使用

首先准备一个临时库,在一个临时文件夹中按此操作:

git clone https://github.com/nlalonde/ruby-bbcode-to-md.git
cd ruby-bbcode-to-md
gem build ruby-bbcode-to-md.gemspec
gem install ruby-bbcode-to-md-0.0.13.gem

退出目录,回到 Discourse 开发目录。用任意文本编辑器编辑 Gemfile 并添加本地的 ruby-bbcode-to-mdmysql2 gem:

gem "ruby-bbcode-to-md", path: "ruby-bbcode-to-md 目录路径"
gem "mysql2"

之后在根目录运行脚本:

bundle exec ruby script/import_scripts/discuz_x.rb bbcode-to-md

(阳天) #2

看来再发展一段时间 就成熟了


(freemangl) #3

正在测试环境中转换dz论坛;
请问这一步如何添加本地的ruby-bbcode-to-md 和 mysql2 gem?
我看到ruby-bbcode-to-md文件夹下有Gemfile和Gemfile.lock 2个文件。


(咖啡白菊) #4

请问站长,PHPBB论坛可以按此方式导入数据吗


(咖啡白菊) #5

站长能不能给出个 PHPBB 转换的教程,非常感谢。


(咖啡白菊) #6

我按照此方法和其他方法转换PHPBB ,出现错误:
/root/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’: cannot load such file – bundler (LoadError)

不知道哪里的问题


(Erick Guan) #7

已经更新了文档,是加到 Discourse 的目录里。

@saluzi001 phpBB3 操作和这并没有什么差别。你需要是一个开发者才能操作导入的整个流程。


(freemangl) #8

1.请问要安装配置mysql2如何进行?在本论坛好像没有找到相关的说明。

2.另外,如果我还是在docker环境中(测试环境)把gemfile和discuz_x.rb下载到discourse的根目录和script/import_scripts/下就可以了吧?不用再单独配置开发环境了吧?

3.还有我看到转换脚本discuz_x.rb中的:
# Set DISCUZX_BASE_DIR to the base directory of your discuz installation. DISCUZX_BASE_DIR = '/webdata/project/bbs' AVATAR_DIR = '/uc_server/data/avatar' ATTACHMENT_DIR = '/data/attachment/forum'

AVATAR_DIR和ATTACHMENT_DIR都是绝对路径;是否需要改为和DISCUZX_BASE_DIR相对应的:

AVATAR_DIR ='/webdata/project/bbs/uc_server/data/avatar' ATTACHMENT_DIR '=/webdata/project/bbs/data/attachment/forum'


关于中文ID注册的支持?(已经做好了,看35楼插件版)
(Erick Guan) #9

gem "mysql2" 就可以了,然后运行命令 bundle install

Docker 里的 Discourse 也有这个文件,但问题是你不知道怎么重启 Discourse 吧,你可以重启试试容器(不是 rebuild)

自然,你肯定要修改到对应的目录,但是下面两个基本不用修改,但要改 DISCUZX_BASE_DIR


(freemangl) #10

请问如何重启容器?应该在哪一步重启容器?
是改完gemfile后,bundle install之前还是之后?还是在运行完转换脚本之后?


(Erick Guan) #11
./launcher stop app
./launcher start app

改完 Gemfile 之后,bundle install 完重启试试吧。

迁移一般使用的是开发者环境而不是 Docker 里的 Discourse。


(Erick Guan) #12

我已经移动了 54 个帖子到新的主题:迁移 Discuz 站点时导入脚本错误


(mingxia) #13

关于discuz转换discourse,这个指南还是可行的么,还是有更新


(mingxia) #14

我一直遇到一个问题,就是无法连接到数据库:

/usr/local/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/lib/mysql2/client.rb:89:in `connect’: Can’t connect to MySQL server on ‘100.99.84.114’ (110) (Mysql2::Error)


(pmule) #15

大家好。我现在需要将一个使用 dxksst_floor 插件实现了“楼中楼”的 Discuz! X 论坛迁移到 discourse。
dxksst_floor 插件生成的表结构如下:

CREATE TABLE `pre_dxksst_floor` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `pid` mediumint(8) unsigned DEFAULT '0',
  /* id of the post to which the "floor" is attached */
  `thisid` mediumint(8) unsigned DEFAULT '0',
  `gradation` smallint(3) DEFAULT '0',
  `uid` mediumint(8) unsigned DEFAULT '0',
  /* id of user who post this "floor" */
  `username` varchar(30) DEFAULT '0',
  /* name of user who post this "floor" */
  `message` mediumtext,
  `dateline` int(10) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `id` (`id`,`pid`)
) ENGINE=MyISAM AUTO_INCREMENT=422 DEFAULT CHARSET=utf8;

其中字段功能的注释是我加上的。
我的问题是:

  1. discourse 有无看起来类似的楼中楼功能?
  2. 如果有,其数据库表结构是什么样的?
  3. 我应当如何 hack 哪些脚本以实现对 dxksst_floor 实现的楼中楼的迁移?

还请各位指点!


(pmule) #16

我现在已经搭好开发环境准备迁移,但在 v2.0.0.beta4 操作时出现错误:
creating users
1 / 242 ( 0.4%) /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:48:in _assign_attribute': unknown attribute 'import_pass' for User. (ActiveModel::UnknownAttributeError) from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:40:inblock in _assign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in each' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in_assign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/attribute_assignment.rb:26:in _assign_attributes' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:33:inassign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/core.rb:337:in initialize' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:innew’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in new' from /home/localadmin/git/discourse/script/import_scripts/base.rb:313:increate_user’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:242:in block in create_users' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:ineach’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:in each' from /home/localadmin/git/discourse/script/import_scripts/base.rb:230:increate_users’
from script/import_scripts/discuz_x.rb:163:in block in import_users' from /home/localadmin/git/discourse/script/import_scripts/base.rb:824:inblock in batches’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:823:in loop' from /home/localadmin/git/discourse/script/import_scripts/base.rb:823:inbatches’
from script/import_scripts/discuz_x.rb:137:in import_users' from script/import_scripts/discuz_x.rb:56:inexecute’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:46:in perform' from script/import_scripts/discuz_x.rb:1064:in


(freemangl) #17

多年后我又回来了,当时研究了东西忘了大半…
现在下决心把dz转换为dis,新的转换脚本中有:
require ‘php_serialize’
require ‘miro’
是否需要把这2个加入到Gemfile中?
gem ‘php_serialize’
gem ‘miro’
然后再bundle install?


还是在运行环境中使用gem install php_serialize miro mysql2?
还是都要做?


(freemangl) #18

你这个问题就是我在这里写的:迁移 Discuz 站点时导入脚本错误