507
edits
mNo edit summary |
Tag: 2017 source edit |
||
| Line 328: | Line 328: | ||
A step by step guide is also available [https://meta.discourse.org/t/importing-from-kunena-3/43776?u=jtraulle on the Discourse forum]. | A step by step guide is also available [https://meta.discourse.org/t/importing-from-kunena-3/43776?u=jtraulle on the Discourse forum]. | ||
Old Kunena releases (2.x and 3.x) can be downloaded from the [https://joomlacode.org/gf/project/kunena/frs/?action=index&br_pkgrlssort_by=package_name&br_pkgrlssort_order=asc JoomlaCode forge]. | |||
===Customized SQL query to get all Kunena users=== | |||
Some old Kunena user that does not have a Joomla! account was not retrieved by the import script. | |||
This SQL query use UNION to get the missing users directly from the <code>kunena_messages</code> table. | |||
For use in https://github.com/discourse/discourse/blob/master/script/import_scripts/kunena3.rb script. | |||
<source lang="SQL"> | |||
--- Main Joomla! users table (original query in script) | |||
SELECT id, username, email, registerDate FROM gvrsi_users | |||
UNION | |||
--- Query to fetch users not present in main Joomla! table that have an email address defined | |||
--- Registration date does not exist so we put that to UNIX EPOCH (01/01/1970, 0h00) | |||
SELECT DISTINCT | |||
userid AS id, | |||
name AS username, | |||
email, | |||
STR_TO_DATE('01,01,1970,12,0','%d,%m,%Y,%h,%i') AS registerDate | |||
FROM gvrsi_kunena_messages | |||
WHERE userid NOT IN(SELECT id FROM gvrsi_users) | |||
AND email IS NOT NULL AND email <> '' | |||
GROUP BY id, username | |||
UNION | |||
--- Query to fetch users not present in main Joomla! table that does not have an email address defined | |||
--- Email address is set to no_email to allow Discourse account creation | |||
--- Registration date does not exist so we put that to UNIX EPOCH (01/01/1970, 0h00) | |||
SELECT DISTINCT | |||
userid AS id, | |||
name AS username, | |||
'no_email' AS email, | |||
STR_TO_DATE('01,01,1970,12,0','%d,%m,%Y,%h,%i') AS registerDate | |||
FROM gvrsi_kunena_messages | |||
WHERE userid NOT IN(SELECT id FROM gvrsi_users) | |||
AND (email IS NULL OR email = '') | |||
AND userid NOT IN( | |||
SELECT DISTINCT userid AS id | |||
FROM gvrsi_kunena_messages | |||
WHERE userid NOT IN(SELECT id FROM gvrsi_users) | |||
AND email IS NOT NULL AND email <> '' | |||
GROUP BY id | |||
) | |||
GROUP BY id, username | |||
ORDER BY id; | |||
</source> | |||
===PostgreSQL query to fix quote blocks=== | |||
After migrating, some quote blocks does not show properly. | |||
That is because we must have a blank line after the [quote] BBCode tag. | |||
<source lang="bash"> | |||
./launcher enter app | |||
sudo -u postgres psql discourse | |||
</source> | |||
<source lang="SQL"> | |||
UPDATE posts | |||
SET raw = regexp_replace(posts.raw, '\[(/)?quote([^]]*)]', E'\n[\\1quote\\2]\n', 'g') | |||
FROM posts_with_bbcode_quotes | |||
WHERE posts.id IN (posts_with_bbcode_quotes.targeted_posts) | |||
RETURNING raw; | |||
UPDATE posts set raw = regexp_replace(raw, '(\[quote=".*").*(])', '\1\2', 'g')'; | |||
</source> | |||
We use the <code>rebake</code> command to rebake HTML formatted texts from '''raw''' column into '''cooked''' column. | |||
<source lang="bash"> | |||
rake posts:rebake | |||
</source> | |||
===PostgreSQL query to fix custom smileys=== | |||
''To come soon'' | |||
==Tentative design== | ==Tentative design== | ||