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`

Add comment


Send

Comments   

+1 Jaidev Sunday, 19th January 2014, 12:06 pm
How to rename reference to database when DB name has been changed?
+1 Joel L Monday, 20th January 2014, 10:47 am
Hi Jaidev,

Do you mean two different servers or different databases?

The script (1st) above needs to be modified using any text editor like notepad or vi. Change the name of the tables as appropriate. Specify the "USE" command if you want to specify which database to look at. I'm not sure if MySQL supports the T-SQL way of referring to other databases:
Code:
SELECT t1.* FROM [server_name_1].[database_name].[schema].[table_name] t1
INNER JOIN
[server_name_2].[database_name].[schema].[table_name] t2
ON t2.id=t1.id


I have heard of using a FEDERATED engine for cross-server commands using MySQL.

Hope that helps!

Joe
+1 Pfefferoni Sunday, 15th December 2013, 8:19 pm
Thanks for the script. Exactly what I was looking for. It completed my migration to Joomla 2.5 :lol:
+2 maxi Wednesday, 24th April 2013, 3:30 pm
Excelente! me funcionooo, muchas gracias!! I mean, thanks a lot :P
-1 alexaner Friday, 5th April 2013, 8:17 am
For non-techies I'd suggest automated tool for JComments conversion
www.cms2cms.com/