迁移 Discuz 站点时导入脚本错误


(神楽坂玲奈) #61

1已解决
2已解决
3不打算改
4已解决
5不打算改
6不打算改
7 -
8 已解决
9 已解决

测试过之后稍后发一版


(freemangl) #62

太屌了,期待你的发布- -

刚刚还在折腾@fantasticfears改过的版本,执行不下去啊= =
你有没有对照看下为啥@fantasticfears要做这些修改:
https://raw.githubusercontent.com/fantasticfears/discourse/discuz_x/script/import_scripts/discuz_x.rb


(神楽坂玲奈) #63

哎我的站跑一遍还是要太久

不知道怎样,没跑完过,理论上是修了,可能还有 bug

不清楚有没有私货残留,自行检查


(freemangl) #64

正在导入测试中…明早看结果。
ps,你的网站挺多的啊- -这次还匿名上传github了= =


(神楽坂玲奈) #65

因为这次直接在 docker 里编辑的,不好拿出来。就下了个 gist 那个 gem 传了


(神楽坂玲奈) #66

发现一个大问题,帖子那里那句 mysql 查询那里会越跑越慢,十万帖子过去之后就查不动了


(freemangl) #67

我这次跑完只用了3小时多点…比以前还快啊- -我是8万多贴。

好像加密方式变了?无法登陆了。


(神楽坂玲奈) #68

嗯对,我也发现了,官方给了个导入加密的方式,我那个插件应该可以弃置了。

在调教中,稍候给解决方案


(神楽坂玲奈) #69

官方的 passwordmigrate 插件已经支持 discuz 的加密方式(其实只是由于 discuz 跟 vbullet 用的一样),于是只要简单按照官方的 import_pass 格式把密码存进去即可。

对于已经导入了的数据,可以通过这个办法来重置:

用 phpmyadmin 登录原有 SQL 并执行查询

SELECT CONCAT("UPDATE user_custom_fields AS a SET value = '", password, ":", salt, "' FROM user_custom_fields AS b WHERE a.user_id = b.user_id AND a.name = 'import_pass' AND b.name = 'import_id' and b.value = '", uid, "';")  FROM `pre_ucenter_members` 

将其导出为 CSV,用文本编辑器批量删掉所有双引号,然后存为 sql 丢给 discourse 的 postgres 运行。


(freemangl) #70

官方的passwordmigrate 插件如何使用呀?没找到相关的地方…如果重新执行导入脚本要如何加载passwordmigrate 插件呢?


(Erick Guan) #71

应该是这个推广商做的脚本:

导入了直接用。前提是 Discuz! 的密码加密方式是里面的其中一种(最上注释):

另导入脚本已经合并到官方目录了


(freemangl) #72

从过年休假中活过来了,还没测试你最新修改过的导入脚本;
不过@zh99998之前更新了一个:https://gist.github.com/9db91e8aafcbc14f4c47
有没有参照他解决的这些问题加入到官方目录中?

另外,我看到你在导入脚本中添加了import_pass: user[‘password_hash’],是不是就可以把dz的加密转换为discourse的了,无需再使用passwordmigrate 插件了?

我还看到你把@最新一版的658行# convert table部分删掉了。
s.gsub!(/\[td\]/i, '<td>') s.gsub!(/\[\/td\]/i, '</td>') s.gsub!(/\[tr\]/i, '<tr>') s.gsub!(/\[\/tr\]/i, '</tr>') s.gsub!(/\[table\]/i, '<table>') s.gsub!(/\[\/table\]/i, '</table>')


(Erick Guan) #73

所有更改已经同步。字段我记得是要配合插件使用的。


#74

导入帖子的时候报错如下 -

creating users
5386 / 5386 (100.0%)
creating categories
33 / 33 (100.0%)
creating topics and posts
/var/lib/gems/2.1.0/gems/rack-mini-profiler-0.9.9.2/lib/patches/db/mysql2.rb:6: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]

– Control frame information -----------------------------------------------
c:0012 p:---- s:0052 e:000051 CFUNC :each
c:0011 p:0018 s:0049 e:000048 METHOD /var/lib/gems/2.1.0/gems/rack-mini-profiler-0.9.9.2/lib/patches/db/mysql2.rb:6
c:0010 p:0054 s:0041 E:000658 METHOD /home/discourse/discourse/script/import_scripts/base.rb:420
c:0009 p:0093 s:0032 E:001c88 BLOCK script/import_scripts/discuz_x.rb:340
c:0008 p:0008 s:0028 e:000027 BLOCK /home/discourse/discourse/script/import_scripts/base.rb:702 [FINISH]
c:0007 p:---- s:0026 e:000025 CFUNC :loop
c:0006 p:0012 s:0023 e:000022 METHOD /home/discourse/discourse/script/import_scripts/base.rb:701
c:0005 p:0071 s:0018 E:001f88 METHOD script/import_scripts/discuz_x.rb:315
c:0004 p:0025 s:0011 E:002328 METHOD script/import_scripts/discuz_x.rb:58
c:0003 p:0029 s:0008 E:001d70 METHOD /home/discourse/discourse/script/import_scripts/base.rb:45
c:0002 p:0092 s:0004 E:000cc8 EVAL script/import_scripts/discuz_x.rb:956 [FINISH]
c:0001 p:0000 s:0002 E:0023d8 TOP [FINISH]

– Ruby level backtrace information ----------------------------------------
script/import_scripts/discuz_x.rb:956:in <main>' /home/discourse/discourse/script/import_scripts/base.rb:45:inperform’
script/import_scripts/discuz_x.rb:58:in execute' script/import_scripts/discuz_x.rb:315:inimport_posts’
/home/discourse/discourse/script/import_scripts/base.rb:701:in batches' /home/discourse/discourse/script/import_scripts/base.rb:701:inloop’
/home/discourse/discourse/script/import_scripts/base.rb:702:in block in batches' script/import_scripts/discuz_x.rb:340:inblock in import_posts’
/home/discourse/discourse/script/import_scripts/base.rb:420:in create_posts' /var/lib/gems/2.1.0/gems/rack-mini-profiler-0.9.9.2/lib/patches/db/mysql2.rb:6:ineach’
/var/lib/gems/2.1.0/gems/rack-mini-profiler-0.9.9.2/lib/patches/db/mysql2.rb:6:in `each’

– C level backtrace information -------------------------------------------
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x188f97) [0x7f0f27632f97]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x189063) [0x7f0f27633063]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x6c833) [0x7f0f27516833]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(rb_bug+0xb3) [0x7f0f27516fa3]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x1203cf) [0x7f0f275ca3cf]
/lib/x86_64-linux-gnu/libc.so.6(+0x352f0) [0x7f0f271152f0]
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.18(mysql_fetch_row+0x81) [0x7f0f2319f6f1]


(freemangl) #76

你最后整合的转换脚本有一处写错了:

141行,定义是的password_hash;但到了169行你改为了import_pass,导致报错:
unknown attribute ‘import_pass’ for User.


另外,是不是discourse的表结构有变动,继续执行的时候又报错了:

/usr/local/lib/ruby/gems/2.5.0/gems/activemodel-5.2.0/lib/active_model/attribute_methods.rb:430:inmethod_missing’: undefined method email_digests' for #<User:0x000055f324056eb0> (NoMethodError)


从 Discuz! X 迁移到 Discourse
(Erick Guan) #77

数据库会随时间改动的,建议你在用的时候顺手把它交到官方去


#78

把这个注释掉,还会有新的错误:

  1. 在这里:

           category.color = Miro::DominantColors.new(File.join('/shared', category.logo_url)).to_hex.first[1, 6] if !color
    
  2. 把上面那行注释掉,继续有下面的错误:

           8641 / 37001 ( 23.4%)  [634 items/min]  Traceback (most recent call last):
                 12: from script/import_scripts/discuz_x.rb:955:in `<main>'
                 11: from /home/betaxab/discourse/script/import_scripts/base.rb:47:in `perform'
                 10: from script/import_scripts/discuz_x.rb:58:in `execute'
                 9: from script/import_scripts/discuz_x.rb:315:in `import_posts'
                 8: from /home/betaxab/discourse/script/import_scripts/base.rb:877:in `batches'
                 7: from /home/betaxab/discourse/script/import_scripts/base.rb:877:in `loop'
                 6: from /home/betaxab/discourse/script/import_scripts/base.rb:878:in `block in batches'
                 5: from script/import_scripts/discuz_x.rb:340:in `block in import_posts'
                 4: from /home/betaxab/discourse/script/import_scripts/base.rb:499:in `create_posts'
                 3: from /home/betaxab/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/mysql2.rb:8:in `each'
                 2: from /home/betaxab/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/mysql2.rb:8:in `each'
                 1: from /home/betaxab/discourse/script/import_scripts/base.rb:500:in `block in create_posts'
           script/import_scripts/discuz_x.rb:364:in `block (2 levels) in import_posts': undefined method `empty?' for #<Mysql2::Result:0x0000559811fcd510> (NoMethodError)
    

不知道该怎么做了,这应该不能简单的注释掉。

注释以后,接下来又发生了错误:

  8641 / 37001 ( 23.4%)  [1410576 items/min]  Traceback (most recent call last):
    12: from script/import_scripts/discuz_x.rb:955:in `<main>'
    11: from /home/betaxab/discourse/script/import_scripts/base.rb:47:in `perform'
    10: from script/import_scripts/discuz_x.rb:58:in `execute'
     9: from script/import_scripts/discuz_x.rb:315:in `import_posts'
     8: from /home/betaxab/discourse/script/import_scripts/base.rb:877:in `batches'
     7: from /home/betaxab/discourse/script/import_scripts/base.rb:877:in `loop'
     6: from /home/betaxab/discourse/script/import_scripts/base.rb:878:in `block in batches'
     5: from script/import_scripts/discuz_x.rb:340:in `block in import_posts'
     4: from /home/betaxab/discourse/script/import_scripts/base.rb:499:in `create_posts'
     3: from /home/betaxab/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/mysql2.rb:8:in `each'
     2: from /home/betaxab/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/mysql2.rb:8:in `each'
     1: from /home/betaxab/discourse/script/import_scripts/base.rb:500:in `block in create_posts'
  script/import_scripts/discuz_x.rb:364:in `block (2 levels) in import_posts': undefined method `empty?' for #<Mysql2::Result:0x0000558231590430> (NoMethodError)

#79

我也遇到了!我注释掉了。


(freemangl) #80

最新的教程和脚本在此:Discourse从安装到Discuz成功迁移,一步一步来的详细指南(面向新手,Discuz迁移到Discourse)