mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Merge pull request #3275 from dandv/patch-3
Add support for MyBB table prefix
This commit is contained in:
commit
f84503315e
1 changed files with 12 additions and 11 deletions
|
@ -7,6 +7,7 @@ require File.expand_path(File.dirname(__FILE__) + "/base.rb")
|
||||||
class ImportScripts::MyBB < ImportScripts::Base
|
class ImportScripts::MyBB < ImportScripts::Base
|
||||||
|
|
||||||
MYBB_DB = "mybb_db"
|
MYBB_DB = "mybb_db"
|
||||||
|
TABLE_PREFIX = "mybb_"
|
||||||
BATCH_SIZE = 1000
|
BATCH_SIZE = 1000
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -32,15 +33,15 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
puts '', "creating users"
|
puts '', "creating users"
|
||||||
|
|
||||||
total_count = mysql_query("SELECT count(*) count
|
total_count = mysql_query("SELECT count(*) count
|
||||||
FROM mybb_users u
|
FROM #{TABLE_PREFIX}users u
|
||||||
JOIN mybb_usergroups g ON g.gid = u.usergroup
|
JOIN #{TABLE_PREFIX}usergroups g ON g.gid = u.usergroup
|
||||||
WHERE g.title != 'Banned';").first['count']
|
WHERE g.title != 'Banned';").first['count']
|
||||||
|
|
||||||
batches(BATCH_SIZE) do |offset|
|
batches(BATCH_SIZE) do |offset|
|
||||||
results = mysql_query(
|
results = mysql_query(
|
||||||
"SELECT uid id, email email, username, regdate, g.title `group`
|
"SELECT uid id, email email, username, regdate, g.title `group`
|
||||||
FROM mybb_users u
|
FROM #{TABLE_PREFIX}users u
|
||||||
JOIN mybb_usergroups g ON g.gid = u.usergroup
|
JOIN #{TABLE_PREFIX}usergroups g ON g.gid = u.usergroup
|
||||||
WHERE g.title != 'Banned'
|
WHERE g.title != 'Banned'
|
||||||
ORDER BY u.uid ASC
|
ORDER BY u.uid ASC
|
||||||
LIMIT #{BATCH_SIZE}
|
LIMIT #{BATCH_SIZE}
|
||||||
|
@ -62,7 +63,7 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
def import_categories
|
def import_categories
|
||||||
results = mysql_query("
|
results = mysql_query("
|
||||||
SELECT fid id, pid parent_id, left(name, 50) name, description
|
SELECT fid id, pid parent_id, left(name, 50) name, description
|
||||||
FROM mybb_forums
|
FROM #{TABLE_PREFIX}forums
|
||||||
ORDER BY pid ASC, fid ASC
|
ORDER BY pid ASC, fid ASC
|
||||||
")
|
")
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
def import_posts
|
def import_posts
|
||||||
puts "", "creating topics and posts"
|
puts "", "creating topics and posts"
|
||||||
|
|
||||||
total_count = mysql_query("SELECT count(*) count from mybb_posts").first["count"]
|
total_count = mysql_query("SELECT count(*) count from #{TABLE_PREFIX}posts").first["count"]
|
||||||
|
|
||||||
batches(BATCH_SIZE) do |offset|
|
batches(BATCH_SIZE) do |offset|
|
||||||
results = mysql_query("
|
results = mysql_query("
|
||||||
|
@ -90,8 +91,8 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
p.uid user_id,
|
p.uid user_id,
|
||||||
p.message raw,
|
p.message raw,
|
||||||
p.dateline post_time
|
p.dateline post_time
|
||||||
FROM mybb_posts p,
|
FROM #{TABLE_PREFIX}posts p,
|
||||||
mybb_threads t
|
#{TABLE_PREFIX}threads t
|
||||||
WHERE p.tid = t.tid
|
WHERE p.tid = t.tid
|
||||||
ORDER BY p.dateline
|
ORDER BY p.dateline
|
||||||
LIMIT #{BATCH_SIZE}
|
LIMIT #{BATCH_SIZE}
|
||||||
|
@ -105,14 +106,14 @@ class ImportScripts::MyBB < ImportScripts::Base
|
||||||
mapped = {}
|
mapped = {}
|
||||||
|
|
||||||
# If you have imported a phpbb forum to mybb previously there might
|
# If you have imported a phpbb forum to mybb previously there might
|
||||||
# be a problem with mybb_threads.firstpost. If these ids are wrong
|
# be a problem with #{TABLE_PREFIX}threads.firstpost. If these ids are wrong
|
||||||
# the thread cannot be imported to discourse as the topic post is
|
# the thread cannot be imported to discourse as the topic post is
|
||||||
# missing. This query retrieves the first_post_id manually. As it
|
# missing. This query retrieves the first_post_id manually. As it
|
||||||
# will decrease the performance it is commented out by default.
|
# will decrease the performance it is commented out by default.
|
||||||
# m['first_post_id'] = mysql_query("
|
# m['first_post_id'] = mysql_query("
|
||||||
# SELECT p.pid id,
|
# SELECT p.pid id,
|
||||||
# FROM mybb_posts p,
|
# FROM #{TABLE_PREFIX}posts p,
|
||||||
# mybb_threads t
|
# #{TABLE_PREFIX}threads t
|
||||||
# WHERE p.tid = #{m['topic_id']} AND t.tid = #{m['topic_id']}
|
# WHERE p.tid = #{m['topic_id']} AND t.tid = #{m['topic_id']}
|
||||||
# ORDER BY p.dateline
|
# ORDER BY p.dateline
|
||||||
# LIMIT 1
|
# LIMIT 1
|
||||||
|
|
Loading…
Reference in a new issue