将 vBulletin 4 论坛迁移到 Discourse

没关系,Jay,我很高兴有人能稍微扶我一把 :smiley:

我唯一担心的是,我所做的更改会导致所有附件都未上传,但却被标记为迁移完成,这样我就不得不重新开始。

您是否知道 Discourse 中的 short_url 属性具体用于什么?我可以随心所欲地更改它,还是必须匹配对象才能在后续的帖子和附件绑定步骤中使用?

2 个赞

short_urlUpload 模型中的一个函数。如果它不起作用,那是因为没有 Upload。我猜接下来我会看看 upload 是否是从 find_upload 返回的。也许它实际上并没有找到它。

2 个赞

输出如下:

我更改了标识性数据(文件名和 S3 存储桶 URL)

#418 可以正常工作,#419 不可以,除了属性数据不同之外,它看起来没问题,对吗?

419 中的文件名使用了下划线,而 418 没有,但之前也有其他文件名使用了下划线,并且工作正常。
其他文件名也比失败的那个长得多,所以我认为这与文件名无关。

2 个赞

上面的帖子有误,@pfaffman 的假设是正确的。

由于我添加了自己的逻辑,脚本在我自己的代码上崩溃了,因此显示的最后一项是最后成功的项。

问题项除了文件名外,所有属性都设置为 nil。

检查 sha1 属性是否为 nil 即可解决问题。

非常感谢 @pfaffman <3

3 个赞

我的人生就是这样!

2 个赞

抱歉又来打扰你了,pfaffman,但这是正常的吗?

3679343 / 3550728 (103.6%)

在上传附件时,似乎超过了 100%?

1 个赞

这意味着获取附件总数的查询与获取附件的查询是不同的。这可能意味着附件的数量是错误的。除非它会一直持续下去,那样的话,就有问题了。:wink:

1 个赞

Attempted @Jack51 s Excelent recap for the steps involved.

However (attempting this on a digitalocean environment) the step for mariadb fails… following those instructions (with 10.5 instead of 10.3) the mysql service is unknown after install.

likely has something to do with that apt-utils wasn’t installed maybe… but also throws
invoke-rc.d: policy-rc.d denied execution of restart.

not sure how to proceed

edit: rebuilt the discourse, made sure to install apt-utils first… still get the same error… can’t start the mariadb server

# apt-get update && apt-get install mariadb-server mariadb-client libmariadbd-dev
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease                                                                                                            
Hit:3 http://deb.debian.org/debian bullseye-backports InRelease                                                                                                          
Hit:4 http://security.debian.org/debian-security bullseye-security InRelease                                                                                             
Hit:5 https://dl.yarnpkg.com/debian stable InRelease                                                                                                                     
Hit:6 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease                                                                                  
Hit:7 https://deb.nodesource.com/node_16.x bullseye InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  galera-4 iproute2 libaio1 libatm1 libbpf0 libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libelf1
  libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libmariadb-dev libmariadb3 libmariadbd19 libmnl0 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl libxtables12
  lsof mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5 mysql-common
Suggested packages:
  iproute2-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test netcat-openbsd
The following NEW packages will be installed:
  galera-4 iproute2 libaio1 libatm1 libbpf0 libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libelf1
  libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libmariadb-dev libmariadb3 libmariadbd-dev libmariadbd19 libmnl0 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl
  libxtables12 lsof mariadb-client mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 mysql-common
0 upgraded, 42 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.9 MB of archives.
After this operation, 227 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bullseye/main amd64 mysql-common all 5.8+1.0.7 [7,464 B]
Get:2 http://deb.debian.org/debian bullseye/main amd64 mariadb-common all 1:10.5.15-0+deb11u1 [36.7 kB]
Get:3 http://deb.debian.org/debian bullseye/main amd64 galera-4 amd64 26.4.11-0+deb11u1 [804 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 libelf1 amd64 0.183-1 [165 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 libbpf0 amd64 1:0.3-2 [98.3 kB]
Get:6 http://deb.debian.org/debian bullseye/main amd64 libmnl0 amd64 1.0.4-3 [12.5 kB]
Get:7 http://deb.debian.org/debian bullseye/main amd64 libxtables12 amd64 1.8.7-1 [45.1 kB]
Get:8 http://deb.debian.org/debian bullseye/main amd64 iproute2 amd64 5.10.0-4 [930 kB]
Get:9 http://deb.debian.org/debian bullseye/main amd64 libdbi-perl amd64 1.643-3+b1 [780 kB]
Get:10 http://deb.debian.org/debian bullseye/main amd64 lsof amd64 4.93.2+dfsg-1.1 [319 kB]
Get:11 http://deb.debian.org/debian bullseye/main amd64 libconfig-inifiles-perl all 3.000003-1 [52.1 kB]
Get:12 http://deb.debian.org/debian bullseye/main amd64 libmariadb3 amd64 1:10.5.15-0+deb11u1 [176 kB]
Get:13 http://deb.debian.org/debian bullseye/main amd64 mariadb-client-core-10.5 amd64 1:10.5.15-0+deb11u1 [783 kB]
Get:14 http://deb.debian.org/debian bullseye/main amd64 mariadb-client-10.5 amd64 1:10.5.15-0+deb11u1 [1,509 kB]
Get:15 http://deb.debian.org/debian bullseye/main amd64 libaio1 amd64 0.3.112-9 [12.5 kB]
Get:16 http://deb.debian.org/debian bullseye/main amd64 libsnappy1v5 amd64 1.1.8-1 [17.9 kB]
Get:17 http://deb.debian.org/debian bullseye/main amd64 mariadb-server-core-10.5 amd64 1:10.5.15-0+deb11u1 [6,689 kB]
Get:18 http://deb.debian.org/debian bullseye/main amd64 mariadb-server-10.5 amd64 1:10.5.15-0+deb11u1 [4,260 kB]
Get:19 http://deb.debian.org/debian bullseye/main amd64 libatm1 amd64 1:2.5.1-4 [71.3 kB]
Get:20 http://deb.debian.org/debian bullseye/main amd64 libhtml-tagset-perl all 3.20-4 [13.0 kB]
Get:21 http://deb.debian.org/debian bullseye/main amd64 liburi-perl all 5.08-1 [90.6 kB]
Get:22 http://deb.debian.org/debian bullseye/main amd64 libhtml-parser-perl amd64 3.75-1+b1 [105 kB]
Get:23 http://deb.debian.org/debian bullseye/main amd64 libcgi-pm-perl all 4.51-1 [224 kB]
Get:24 http://deb.debian.org/debian bullseye/main amd64 libfcgi0ldbl amd64 2.4.2-2 [26.1 kB]
Get:25 http://deb.debian.org/debian bullseye/main amd64 libfcgi-perl amd64 0.79+ds-2 [27.6 kB]
Get:26 http://deb.debian.org/debian bullseye/main amd64 libcgi-fast-perl all 1:2.15-1 [12.1 kB]
Get:27 http://deb.debian.org/debian bullseye/main amd64 libclone-perl amd64 0.45-1+b1 [15.4 kB]
Get:28 http://deb.debian.org/debian bullseye/main amd64 libdbd-mariadb-perl amd64 1.21-3 [110 kB]
Get:29 http://deb.debian.org/debian bullseye/main amd64 libencode-locale-perl all 1.05-1.1 [13.2 kB]
Get:30 http://deb.debian.org/debian bullseye/main amd64 libfcgi-bin amd64 2.4.2-2 [12.9 kB]
Get:31 http://deb.debian.org/debian bullseye/main amd64 libhtml-template-perl all 2.97-1.1 [66.2 kB]
Get:32 http://deb.debian.org/debian bullseye/main amd64 libtimedate-perl all 2.3300-2 [39.3 kB]
Get:33 http://deb.debian.org/debian bullseye/main amd64 libhttp-date-perl all 6.05-1 [10.4 kB]
Get:34 http://deb.debian.org/debian bullseye/main amd64 libio-html-perl all 1.004-2 [16.1 kB]
Get:35 http://deb.debian.org/debian bullseye/main amd64 liblwp-mediatypes-perl all 6.04-1 [19.9 kB]
Get:36 http://deb.debian.org/debian bullseye/main amd64 libhttp-message-perl all 6.28-1 [79.6 kB]
Get:37 http://deb.debian.org/debian bullseye/main amd64 libmariadb-dev amd64 1:10.5.15-0+deb11u1 [185 kB]
Get:38 http://deb.debian.org/debian bullseye/main amd64 libmariadbd19 amd64 1:10.5.15-0+deb11u1 [4,917 kB]
Get:39 http://deb.debian.org/debian bullseye/main amd64 libmariadbd-dev amd64 1:10.5.15-0+deb11u1 [6,085 kB]
Get:40 http://deb.debian.org/debian bullseye/main amd64 libterm-readkey-perl amd64 2.38-1+b2 [27.8 kB]
Get:41 http://deb.debian.org/debian bullseye/main amd64 mariadb-client all 1:10.5.15-0+deb11u1 [35.2 kB]
Get:42 http://deb.debian.org/debian bullseye/main amd64 mariadb-server all 1:10.5.15-0+deb11u1 [35.3 kB]
Fetched 28.9 MB in 0s (124 MB/s)             
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 38903 files and directories currently installed.)
Preparing to unpack .../00-mysql-common_5.8+1.0.7_all.deb ...
Unpacking mysql-common (5.8+1.0.7) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../01-mariadb-common_1%3a10.5.15-0+deb11u1_all.deb ...
Unpacking mariadb-common (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package galera-4.
Preparing to unpack .../02-galera-4_26.4.11-0+deb11u1_amd64.deb ...
Unpacking galera-4 (26.4.11-0+deb11u1) ...
Selecting previously unselected package libelf1:amd64.
Preparing to unpack .../03-libelf1_0.183-1_amd64.deb ...
Unpacking libelf1:amd64 (0.183-1) ...
Selecting previously unselected package libbpf0:amd64.
Preparing to unpack .../04-libbpf0_1%3a0.3-2_amd64.deb ...
Unpacking libbpf0:amd64 (1:0.3-2) ...
Selecting previously unselected package libmnl0:amd64.
Preparing to unpack .../05-libmnl0_1.0.4-3_amd64.deb ...
Unpacking libmnl0:amd64 (1.0.4-3) ...
Selecting previously unselected package libxtables12:amd64.
Preparing to unpack .../06-libxtables12_1.8.7-1_amd64.deb ...
Unpacking libxtables12:amd64 (1.8.7-1) ...
Selecting previously unselected package iproute2.
Preparing to unpack .../07-iproute2_5.10.0-4_amd64.deb ...
Unpacking iproute2 (5.10.0-4) ...
Selecting previously unselected package libdbi-perl:amd64.
Preparing to unpack .../08-libdbi-perl_1.643-3+b1_amd64.deb ...
Unpacking libdbi-perl:amd64 (1.643-3+b1) ...
Selecting previously unselected package lsof.
Preparing to unpack .../09-lsof_4.93.2+dfsg-1.1_amd64.deb ...
Unpacking lsof (4.93.2+dfsg-1.1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../10-libconfig-inifiles-perl_3.000003-1_all.deb ...
Unpacking libconfig-inifiles-perl (3.000003-1) ...
Selecting previously unselected package libmariadb3:amd64.
Preparing to unpack .../11-libmariadb3_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking libmariadb3:amd64 (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package mariadb-client-core-10.5.
Preparing to unpack .../12-mariadb-client-core-10.5_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking mariadb-client-core-10.5 (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package mariadb-client-10.5.
Preparing to unpack .../13-mariadb-client-10.5_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking mariadb-client-10.5 (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../14-libaio1_0.3.112-9_amd64.deb ...
Unpacking libaio1:amd64 (0.3.112-9) ...
Selecting previously unselected package libsnappy1v5:amd64.
Preparing to unpack .../15-libsnappy1v5_1.1.8-1_amd64.deb ...
Unpacking libsnappy1v5:amd64 (1.1.8-1) ...
Selecting previously unselected package mariadb-server-core-10.5.
Preparing to unpack .../16-mariadb-server-core-10.5_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking mariadb-server-core-10.5 (1:10.5.15-0+deb11u1) ...
Setting up mysql-common (5.8+1.0.7) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mariadb-common (1:10.5.15-0+deb11u1) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.5.
(Reading database ... 39534 files and directories currently installed.)
Preparing to unpack .../00-mariadb-server-10.5_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking mariadb-server-10.5 (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package libatm1:amd64.
Preparing to unpack .../01-libatm1_1%3a2.5.1-4_amd64.deb ...
Unpacking libatm1:amd64 (1:2.5.1-4) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../02-libhtml-tagset-perl_3.20-4_all.deb ...
Unpacking libhtml-tagset-perl (3.20-4) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../03-liburi-perl_5.08-1_all.deb ...
Unpacking liburi-perl (5.08-1) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../04-libhtml-parser-perl_3.75-1+b1_amd64.deb ...
Unpacking libhtml-parser-perl (3.75-1+b1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../05-libcgi-pm-perl_4.51-1_all.deb ...
Unpacking libcgi-pm-perl (4.51-1) ...
Selecting previously unselected package libfcgi0ldbl:amd64.
Preparing to unpack .../06-libfcgi0ldbl_2.4.2-2_amd64.deb ...
Unpacking libfcgi0ldbl:amd64 (2.4.2-2) ...
Selecting previously unselected package libfcgi-perl:amd64.
Preparing to unpack .../07-libfcgi-perl_0.79+ds-2_amd64.deb ...
Unpacking libfcgi-perl:amd64 (0.79+ds-2) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../08-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libclone-perl.
Preparing to unpack .../09-libclone-perl_0.45-1+b1_amd64.deb ...
Unpacking libclone-perl (0.45-1+b1) ...
Selecting previously unselected package libdbd-mariadb-perl.
Preparing to unpack .../10-libdbd-mariadb-perl_1.21-3_amd64.deb ...
Unpacking libdbd-mariadb-perl (1.21-3) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../11-libencode-locale-perl_1.05-1.1_all.deb ...
Unpacking libencode-locale-perl (1.05-1.1) ...
Selecting previously unselected package libfcgi-bin.
Preparing to unpack .../12-libfcgi-bin_2.4.2-2_amd64.deb ...
Unpacking libfcgi-bin (2.4.2-2) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../13-libhtml-template-perl_2.97-1.1_all.deb ...
Unpacking libhtml-template-perl (2.97-1.1) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../14-libtimedate-perl_2.3300-2_all.deb ...
Unpacking libtimedate-perl (2.3300-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../15-libhttp-date-perl_6.05-1_all.deb ...
Unpacking libhttp-date-perl (6.05-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../16-libio-html-perl_1.004-2_all.deb ...
Unpacking libio-html-perl (1.004-2) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../17-liblwp-mediatypes-perl_6.04-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.04-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../18-libhttp-message-perl_6.28-1_all.deb ...
Unpacking libhttp-message-perl (6.28-1) ...
Selecting previously unselected package libmariadb-dev.
Preparing to unpack .../19-libmariadb-dev_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking libmariadb-dev (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package libmariadbd19:amd64.
Preparing to unpack .../20-libmariadbd19_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking libmariadbd19:amd64 (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package libmariadbd-dev.
Preparing to unpack .../21-libmariadbd-dev_1%3a10.5.15-0+deb11u1_amd64.deb ...
Unpacking libmariadbd-dev (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../22-libterm-readkey-perl_2.38-1+b2_amd64.deb ...
Unpacking libterm-readkey-perl (2.38-1+b2) ...
Selecting previously unselected package mariadb-client.
Preparing to unpack .../23-mariadb-client_1%3a10.5.15-0+deb11u1_all.deb ...
Unpacking mariadb-client (1:10.5.15-0+deb11u1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../24-mariadb-server_1%3a10.5.15-0+deb11u1_all.deb ...
Unpacking mariadb-server (1:10.5.15-0+deb11u1) ...
Setting up libconfig-inifiles-perl (3.000003-1) ...
Setting up galera-4 (26.4.11-0+deb11u1) ...
Setting up libfcgi0ldbl:amd64 (2.4.2-2) ...
Setting up libclone-perl (0.45-1+b1) ...
Setting up libhtml-tagset-perl (3.20-4) ...
Setting up liblwp-mediatypes-perl (6.04-1) ...
Setting up libfcgi-bin (2.4.2-2) ...
Setting up libencode-locale-perl (1.05-1.1) ...
Setting up libatm1:amd64 (1:2.5.1-4) ...
Setting up libsnappy1v5:amd64 (1.1.8-1) ...
Setting up libmnl0:amd64 (1.0.4-3) ...
Setting up libio-html-perl (1.004-2) ...
Setting up libmariadb3:amd64 (1:10.5.15-0+deb11u1) ...
Setting up libxtables12:amd64 (1.8.7-1) ...
Setting up lsof (4.93.2+dfsg-1.1) ...
Setting up libmariadb-dev (1:10.5.15-0+deb11u1) ...
Setting up libtimedate-perl (2.3300-2) ...
Setting up libfcgi-perl:amd64 (0.79+ds-2) ...
Setting up libterm-readkey-perl (2.38-1+b2) ...
Setting up libaio1:amd64 (0.3.112-9) ...
Setting up libelf1:amd64 (0.183-1) ...
Setting up liburi-perl (5.08-1) ...
Setting up libdbi-perl:amd64 (1.643-3+b1) ...
Setting up mariadb-server-core-10.5 (1:10.5.15-0+deb11u1) ...
Setting up libhttp-date-perl (6.05-1) ...
Setting up libmariadbd19:amd64 (1:10.5.15-0+deb11u1) ...
Setting up libdbd-mariadb-perl (1.21-3) ...
Setting up mariadb-client-core-10.5 (1:10.5.15-0+deb11u1) ...
Setting up mariadb-client-10.5 (1:10.5.15-0+deb11u1) ...
Setting up libhtml-parser-perl (3.75-1+b1) ...
Setting up libbpf0:amd64 (1:0.3-2) ...
Setting up libhttp-message-perl (6.28-1) ...
Setting up libmariadbd-dev (1:10.5.15-0+deb11u1) ...
Setting up mariadb-client (1:10.5.15-0+deb11u1) ...
Setting up iproute2 (5.10.0-4) ...
Setting up libcgi-pm-perl (4.51-1) ...
Setting up libhtml-template-perl (2.97-1.1) ...
Setting up mariadb-server-10.5 (1:10.5.15-0+deb11u1) ...
invoke-rc.d: could not determine current runlevel
Stopping MariaDB database server: mariadbd.
invoke-rc.d: could not determine current runlevel
Starting MariaDB database server: mariadbd.
Setting up mariadb-server (1:10.5.15-0+deb11u1) ...
Setting up libcgi-fast-perl (1:2.15-1) ...
Processing triggers for libc-bin (2.31-13+deb11u3) ...
root@discourse-one-app:/# service mysql start
mysql: unrecognized service
1 个赞

好的……我让导入脚本运行了,尽管在导入用户时出现了一个错误。

有什么办法可以解决这个问题吗?

root@discourse-one-app:/var/www/discourse# su discourse -c 'bundle exec ruby script/import_scripts/vbulletin.rb'
root:password@localhost wants vbulletin
Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...

importing groups...
       16 / 16 (100.0%)  [126440 items/min]   
importing users
Traceback (most recent call last):
        14: from script/import_scripts/vbulletin.rb:999:in `<main>'
        13: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
        12: from script/import_scripts/vbulletin.rb:82:in `execute'
        11: from script/import_scripts/vbulletin.rb:129:in `import_users'
        10: from /var/www/discourse/script/import_scripts/base.rb:907:in `batches'
         9: from /var/www/discourse/script/import_scripts/base.rb:907:in `loop'
         8: from /var/www/discourse/script/import_scripts/base.rb:908:in `block in batches'
         7: from script/import_scripts/vbulletin.rb:152:in `block in import_users'
         6: from /var/www/discourse/script/import_scripts/base.rb:264:in `create_users'
         5: from /var/www/discourse/script/import_scripts/base.rb:264:in `each'
         4: from /var/www/discourse/script/import_scripts/base.rb:265:in `block in create_users'
         3: from script/import_scripts/vbulletin.rb:170:in `block (2 levels) in import_users'
         2: from script/import_scripts/vbulletin.rb:990:in `parse_timestamp'
         1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/tzinfo-2.0.4/lib/tzinfo/timezone.rb:575:in `utc_to_local'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/tzinfo-2.0.4/lib/tzinfo/timestamp.rb:136:in `for': Integer values are not supported (ArgumentError)

更新:已找出问题所在。

由于 Discourse 现在需要 TZInfo 2.x,迁移脚本目前已损坏,因为它使用了 TZInfo 1.2.x 和 2.x 中已更改的函数。

编辑
临时修复以使系统正常运行:

修复 TZInfo 2.x 导致时区导入失败
注意:我不确定这是否是所有情况下的最佳修复方法,但对于我数据库中具有格式正确的纪元时间戳的日期,这似乎效果很好。

第 990 行
已更改

    Time.zone.at(@tz.utc_to_local(timestamp))

    Time.zone.at(timestamp)

脚本因最后访问时间为 nil 值而崩溃
最后访问时间实际上是从数据库导入的。因此,我们将其添加到正在获取的内容中。

第 131 行
已更改

          SELECT userid
               , username
               , homepage
               , usertitle
               , usergroupid
               , joindate
               , email
               , password
               , salt
            FROM #{TABLE_PREFIX}user
           WHERE userid > #{last_user_id}
        ORDER BY userid
           LIMIT #{BATCH_SIZE}

          SELECT userid
               , username
               , homepage
               , usertitle
               , usergroupid
               , joindate
               , lastvisit
               , email
               , password
               , salt
            FROM #{TABLE_PREFIX}user
           WHERE userid > #{last_user_id}
        ORDER BY userid
           LIMIT #{BATCH_SIZE}
6 个赞

我遇到了同样的问题,不确定 Haddoq 在说修改第 990 行时指的是哪个文件。
对其他人来说,它是 vbulletin5.rb

1 个赞

在导入帖子时,通过向 vbulletin5.rb 添加一些错误处理,解决了“UTF-8 中无效的字节序列”问题。

这是我用第 450 行替换的代码。我不会 Ruby,所以这有点像个 hack。

    begin
      raw = raw.gsub(/(\\\\r)?\\\\n/, "\\n")
        .gsub("\\t", "\\t")
    rescue => error
        p error.message
        p raw
    end

当我重新运行脚本时,它将有问题的帖子打印到了控制台。

然后我搜索了控制台中的一些唯一文本,并在 MySQL 中运行了以下命令:

select * from vb_text where rawtext LIKE '%and then my fish ate my car keys%'  limit 10;

这给了有问题的行的 nodeid,所以我用它来更新该行,我可以将其输入到修复了错误文本的查询中。

update vb_text set rawtext='POST FAILED TO MIGRATE (or a corrected version of the post)' where nodeid IN (159079);
2 个赞

你好!你能分享一下你是如何检查 sha1 属性是否为 nil 的代码吗?

我遇到了同样的问题:
/discourse/app/models/upload.rb:246:in `base62_sha1': undefined method `hex' for nil:NilClass (NoMethodError)
谢谢!


附言//
对于可能遇到相同问题的人。
在文件 discourse\app\models\upload.rb 中找到:
“#{Upload.base62_sha1(sha1)}#{extension.present? ? \”.#{extension}\” : \"\"}”
替换为:

    除非 sha1.nil?
      “#{Upload.base62_sha1(sha1)}#{extension.present? ? \”.#{extension}\” : \"\"}”
    结束

另外,我还遇到了:
discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/core_ext/time/calculations.rb:56:in `at': can't convert nil into an exact number (TypeError)
错误。
要修复此问题:
discourse\script\import_scripts\vbulletin.rb 中找到:

        user.suspended_at = parse_timestamp(user["bandate"])
        user.suspended_till = 200.years.from_now

并替换为:

        user.suspended_at = parse_timestamp(user["bandate"].to_i)
        user.suspended_till = 200.years.from_now.to_i
1 个赞

您好,
我正在使用 Ubuntu 22.04 LTS,并希望将 vBulletin 转换为 Discourse。

DB_HOST = "172.17.0.5"
DB_USER = "root"
DB_PASSWORD = "*******"

当我输入 RAILS_ENV=production bundle exec ruby script/import_scripts/vbulletin.rb 时,
会出现此错误:

1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/mini_profiler/profiling_methods.rb:83:in `profile_method'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/mini_profiler/profiling_methods.rb:83:in `alias_method': undefined method `call' for class `Redis::Client' (NameError)
Did you mean?  caller

我该如何解决?

您使用的是开发安装还是标准安装?我认为您不需要添加 RAILS_ENV=production,因为您没有生产数据库。

我使用的是标准安装。
参考了 https://www.vultr.com/docs/how-to-install-discourse-on-ubuntu-20-04/。
我无法在 docker 安装中使用 Mysql。我在 discourse docker 镜像中安装了 MariaDB。

root@localhost-app:/var/www/discourse# service mysql start
mysql: unrecognized service
root@localhost-app:/var/www/discourse#

所以我创建了一个 mysql docker 镜像并将我的 vBulletine 数据库上传到那里。mysql docker 镜像的 IP 地址是 172.17.0.5。

谢谢。

我按照以下步骤操作:
遵循了使用 Docker 容器

  1. 标准安装 discourse。(discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub)。
  2. 下载 mysql docker 并将我的 vBulletin 数据库上传到那里。
    我使用 root@localhost:/opt/discourse# mysql -h 172.17.0.5 -P 3306 --protocol=tcp -u root -p 命令进行了检查。
  3. root@localhost:/opt/discourse#./launcer enter app
  4. apt-get update && apt-get install libmysqlclient-dev mysql-server-5.7 失败。
    因此,我安装了 apt-get update && apt-get install libmariadb-dev mariadb-server
  5. 我无法在 docker 中运行 mysql。
root@localhost-app:/var/www/discourse# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
在整个 docker 目录中都没有 mysqld.sock。无法通过 `find` 命令找到。
root@localhost-app:/var/www/discourse# sudo service mysql start
mysql: unrecognized service
  1. 我参考了 https://www.baeldung.com/docker-cant-connect-local-mysql 并在“172.17.0.5”上使用了 mysql docker 镜像。
gem install mysql2
gem install php_serialize
在安装 libmariadb-dev 之前,`gem install mysql2` 不起作用。
  1. 运行
su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
出现错误,所以我删除了 gemfile.lock 和 .bundle 文件并重试。
  1. 之后我尝试了。
export DB_NAME="vb3" # Change this to the name of VB3 database.
export DB_USER="root"
export DB_PASSWORD="mypassword"
export DB_HOST="172.17.0.5"
cd /var/www/discourse
su discourse -c 'bundle exec ruby script/import_scripts/vbulletin.rb'
但是脚本生成了错误。
1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/mini_profiler/profiling_methods.rb:83:in `profile_method'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/mini_profiler/profiling_methods.rb:83:in `alias_method': undefined method `call' for class `Redis::Client' (NameError)
Did you mean?  caller
我该如何解决?
谢谢。

我遇到了同样的问题,你已经解决了吗?谢谢!

我也遇到了这个,你成功绕过它了吗?

我找到了用于匹配以下内容的正则表达式:
# [QUOTE=<username>;<post_id>]...[/QUOTE]
但没有考虑到用户名和帖子 ID 可能被双引号包围的可能性:


因此,大部分引用在迁移到 Discourse 时,“丢失”了其来源链接:

这里是成功迁移的:


这里是丢失了来源链接的:

据我所知,这发生在:

并且可以通过类似以下方式轻松修复:
raw.gsub!(%r{\\[quote=\"?([^;]+);(\\d+)\"?\\](.+?)\\[/quote\\]}im) do

但看起来当嵌套引用也存在时,这会停止工作:

有人有成功迁移所有引用的解决方案吗?