Migrate JComments from Joomla 1.5.x to Joomla 2.5.x

Thought I'd add the migration script I've been using to test my JComments migration from my Joomla CMS site version 1.5.20 to Joomla CMS site version 2.5.6.

DISCLAIMER

  1. I do not work for either Joomla or JoomlaTune (Jcomments)
  2. This script is provided as is without warranty
  3. If you do not understand what this script is doing, let someone who does run it instead

INSTALL INSTRUCTIONS

  1. Install JComments on your upgraded website (at time of print: Jcomments v2.3.0 on Joomla v2.5.4)
  2. Copy the below script to a text file
    1. Change the database names to match your setup
    2. Change the table name prefixes to match your setup
  3. Run the modified SQL script against your database.
Note: It is not advisable to run this on a production website!
-- --------------------------------------------------------------------------------
-- MIGRATION SCRIPT FOR JCOMMENTS IN JOOMLA v1.5.x TO JOOMLA v2.5.x
-- --------------------------------------------------------------------------------

-- NOTE: Replace string "mydb_livecopy_j15" to your Joomla 1.5.x database name
-- -- -- (example: "anolddatabase") -- 9 occurrences
-- NOTE: Replace string "mydb_livecopy_j15.myprefix_" to your Joomla 1.5.x database name & table prefix
-- -- -- (example: "anolddatabase.jos_") -- 8 occurrences

-- NOTE: Replace string "mydb_upgrade_j25" to your Joomla 2.5.x database name
-- -- -- (example: "anewdatabase") -- 9 occurrences
-- NOTE: Replace string "mydb_upgrade_j25.myprefix_" to your Joomla 2.5.x database name & table prefix
-- -- -- (example: "anewdatabase.rndpfx1_") -- 8 occurrences

-- --------------------------------------------------------------------------------
-- _jcomments
-- --------------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments
	(
		id, parent, thread_id, path, level, object_id, object_group, object_params, lang,
		userid, name, username, email, homepage, title, comment, ip, date, isgood, ispoor,
		published, subscribe, source, source_id, checked_out, checked_out_time, editor
	)
SELECT
	id, parent,
	CASE WHEN SUBSTRING(path, LOCATE(',', path)+1, LOCATE(',', path, 2))='' THEN 0
	ELSE SUBSTRING(path, LOCATE(',', path)+1, LOCATE(',', path, 2)) END AS thread_id,
	path, level, object_id, object_group, object_params, lang,
	userid, name, username, email, homepage, title, comment, ip, date, isgood, ispoor,
	published, subscribe, source, source_id, checked_out, checked_out_time, editor
FROM
	mydb_livecopy_j15.myprefix_jcomments;


-- --------------------------------------------------------------------------------
-- _jcomments_custom_bbcodes
-- --------------------------------------------------------------------------------

-- NOTE: This is disabled as the new version includes the old bbcodes setup (no change)

-- INSERT INTO
-- 	mydb_upgrade_j25.myprefix_jcomments_custom_bbcodes
-- 	(
-- 		id, `name`, simple_pattern, simple_replacement_html, simple_replacement_text, pattern,
-- 		replacement_html, replacement_text, button_acl, button_open_tag, button_close_tag,
-- 		button_title, button_prompt, button_image, button_css, button_enabled, ordering,
-- 		published
-- 	)
-- SELECT
-- 	id, `name`, simple_pattern, simple_replacement_html, simple_replacement_text, pattern,
-- 	replacement_html, replacement_text, button_acl, button_open_tag, button_close_tag,
-- 	button_title, button_prompt, button_image, button_css, button_enabled, ordering,
-- 	published
-- FROM
-- 	mydb_livecopy_j15.myprefix_jcomments_custom_bbcodes;



-- --------------------------------------------------------------------------------
-- _jcomments_reports
-- --------------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments_reports
	(
		id, commentid, userid, name, ip, date, reason, status
	)
SELECT
	id, commentid, userid, name, ip, date, reason, status
FROM
	mydb_livecopy_j15.myprefix_jcomments_reports;


-- --------------------------------------------------------------------------------
-- _jcomments_settings -- ignored as this will load factory settings
-- --------------------------------------------------------------------------------
/*
INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments_settings
	(
		component, lang, name, value
	)
SELECT
	component, lang, name, value
FROM
	mydb_livecopy_j15.myprefix_jcomments_settings;
*/

-- --------------------------------------------------------------------------------
-- _jcomments_subscriptions
-- --------------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments_subscriptions
	(
		id, object_id, object_group, lang, userid, name, email, hash, published
	)
SELECT
	id, object_id, object_group, lang, userid, name, email, hash, published
FROM
	mydb_livecopy_j15.myprefix_jcomments_subscriptions;


-- source=???

-- --------------------------------------------------------------------------------
-- _jcomments_version
-- --------------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments_version
	(
		version, previous, installed, updated
	)
SELECT
	version, previous, installed, updated
FROM
	mydb_livecopy_j15.myprefix_jcomments_version;


-- --------------------------------------------------------------------------------
-- _jcomments_votes
-- --------------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade_j25.myprefix_jcomments_votes
	(
		id, commentid, userid, ip, date, value
	)
SELECT
	id, commentid, userid, ip, date, value
FROM
	mydb_livecopy_j15.myprefix_jcomments_votes;




-- --------------------------------------------------------------------------------
-- _jcomments_objects  *** NEW FOR JOOMLA 2.5.X
-- --------------------------------------------------------------------------------


Post-Installation

Go to JComments Settings and specify the same "Choose categories for JComments to work in" as you have for your 1.5 website. The above script ignores your previous settings and leaves the factory settings that come with the JComments extension. Check all JComments settings are what you want using the Joomla Admin interface.

If the article IDs match then the comments will also match. If however your article IDs don't match in both versions of your site, consider using the following update script, this will change the IDs of the JComments comments to be associated to articles from your Joomla 2.5 site (no changes to article IDs but backup your original database (J1.5) anyway before running the following):

UPDATE 
	my_joomla_1_5_db.my_1_5_db_prefix_content j1a,    -- Joomla 1.5.x Content
	my_joomla_1_5_db.my_1_5_db_prefix_jcomments j1b,  -- Joomla 1.5.x JComments
	my_joomla_2_5_db.my_2_5_db_prefix_content j2a,    -- Joomla 2.5.x Content
	my_joomla_2_5_db.my_2_5_db_prefix_jcomments j2b   -- Joomla 2.5.x JComments

SET 
	j2b.`object_id`=j2a.`id`

WHERE
	j1a.`alias`=j2a.`alias`

AND
	j1a.`id`=j1b.`object_id`

AND	
	j2b.`comment`=j1b.`comment`


Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.