Migrating from Joomla 2.5.x to 3.4.x

What?
This is an article to document the migration of a Joomla! CMS running version 2.5.11 to an instance of Joomla! CMS version 3.4.1. I would consider the below instructions an ALPHA version as it is considered unstable for official use... Saying that this is how I upgraded my own personal website: www.joellipman.com.

This article assumes you are familiar with upgrading a Joomla! CMS and running MySQL statements against your database.

For the purposes of this article, we will refer to the live/current/production website running Joomla v2.5 as "v25" and the new Joomla instance as "v34". Their respective database tables are prefixed with "v25_" and "v34_". So an example MySQL statement will be:
`v25_db`.`v25_tablename`
-- with the database name and table prefix of database you are READING from (eg. `myuser_joellipmancom_mysitedb`.`lkdjf_content`)

`v34_db`.`v34_tablename`
-- with the database name and table prefix of database you are WRITING to (eg. `myuser_joellipmancom_mysitedb`.`ejf1r_content`)


How?
Here's a brief outline of the whole process:
  1. Backups
  2. Install
  3. Users
  4. Categories -- unstable
  5. Content
  6. Weblinks
  7. 3rd-party: JComments

Here's a less brief outline of the whole process:
Pre-Notes: To begin with, ensure that no extra new users are created in the v34 system other than the user who is installing it.
  1. Preparation:
    1. Backup your Joomla v2.5.x database and website files
    2. Note the CURRENT super user identification number "ID" and alias (name)
    3. Ensure all items are "checked-in" (Do a "Global Check In")
  2. Install new Joomla:
    1. Install Joomla! CMS v3.4.x
    2. with Demo Content (eg. 3rd-party QuickStarts):
      • [Personal Option] Modify admin ID to NOT use a text editor (ie. "Text-editor=None")
      • If you are going to delete an object (eg. contacts), make a note on its contents or embedded code specific to the template.
  3. Copy over Users:
    1. Rename the Admin ID in the new v34 system to match your v25 system.
    2. Check your usergroups are the same in both systems. Import new ones.
    3. Copy all users except the v25 admin to your v34 database (with status=blocked)
    4. Copy over user group mappings
    5. Update new system admin details with old (name, registration date, etc).
  4. Copy over Categories:
    • It is recommended to do this via the GUI and then associate the IDs to your content, weblinks, etc.
    • The thing to watch out for is associating the categories with respect to the assets table.
    • To do this via DB commands, refer to how the weblinks categories are added.
  5. Copy over Content:
    • We want to maintain the same IDs for articles in case SEO settings will be enabled and the ID is in the URL.
    • We will insert assets as new ones but associate these to the v25 assets.
    • Categories will be associated by comparing both databases' content tables.
  6. Copy over Weblinks:
    1. Import the weblinks
    2. Copy over the weblink categories
    3. Copy over the weblink category assets
  7. Third-party component: JComments:
    • This will be a copy of two systems running JComments version 3.x
    • The MySQL scripts will copy over each table in turn
  8. Configure and Brand your new Joomla site
  9. Activate Users
Post-Notes: Activating users should be done as the last step of this migration.

Rename admin ID in the UPGRADE database
We want to make sure that the new user ID doesn't exist in our upgraded system because we may have a user with that ID in the old system who might inherit privileges they shouldn't have. This script has been adapted to change the Admin ID to a number that hasn't been taken yet or to use the current one and is specified as a local variable.

-- Specify v2.5.x admin ID and v3.4.x admin ID
SET @v25_admin_id=42;			-- Set this to the ID number of the user in your Joomla 2.5.x
SET @v25_admin_alias='Webmaster';	-- Set this to the name of the admin user in your Joomla 2.5.x
SET @v34_admin_id=443;			-- Set this to the ID number of the user in your Joomla 3.x
SET @v34_admin_alias='Webmaster';	-- Set this to the name of the admin user in your Joomla 3.x

-- Banners:
UPDATE `v34_db`.`v34_banners` 
SET `created_by` = @v25_admin_id, `created_by_alias` = @v25_admin_alias 
WHERE `created_by` = @v34_admin_id;
UPDATE `v34_db`.`v34_banners` 
SET `modified_by` = @v25_admin_id 
WHERE `modified_by` = @v34_admin_id;

-- Categories:
UPDATE `v34_db`.`v34_categories` 
SET `created_user_id` = @v25_admin_id 
WHERE `created_user_id` = @v34_admin_id;
UPDATE `v34_db`.`v34_categories` 
SET `modified_user_id` = @v25_admin_id 
WHERE `modified_user_id` = @v34_admin_id;

-- Contact Details: (you should clear this list as you will import them all!)
-- DELETE FROM `v34_db`.`v34_contact_details` WHERE `v34_contact_details`.`id` >= 1
-- ALTER TABLE `v34_db`.`v34_contact_details` AUTO_INCREMENT = 1

-- Content:
UPDATE `v34_db`.`v34_content` 
SET `created_by` = @v25_admin_id, `created_by_alias` = @v25_admin_alias 
WHERE `created_by` = @v34_admin_id;
UPDATE `v34_db`.`v34_content` 
SET `modified_by` = @v25_admin_id 
WHERE `modified_by` = @v34_admin_id;

-- Tags:
UPDATE `v34_db`.`v34_tags` 
SET `created_user_id` = @v25_admin_id 
WHERE `created_user_id`= @v34_admin_id;
UPDATE `v34_db`.`v34_tags` 
SET `modified_user_id` = @v25_admin_id 
WHERE `modified_user_id`= @v34_admin_id;

-- UCM Content:
UPDATE `v34_db`.`v34_ucm_content` 
SET `core_created_user_id` = @v25_admin_id 
WHERE `core_created_user_id`= @v34_admin_id;
UPDATE `v34_db`.`v34_ucm_content` 
SET `core_modified_user_id` = @v25_admin_id 
WHERE `core_modified_user_id`= @v34_admin_id;

-- UCM History:
UPDATE `v34_db`.`v34_ucm_history` 
SET `editor_user_id` = @v25_admin_id 
WHERE `editor_user_id` = @v34_admin_id;

-- User Usergroup Map:
UPDATE `v34_db`.`v34_user_usergroup_map` 
SET `user_id` = @v25_admin_id 
WHERE `user_id` = @v34_admin_id;

-- Users:
UPDATE `v34_db`.`v34_users` 
SET `id` = @v25_admin_id 
WHERE `id` = @v34_admin_id;
These are the Joomla! core ones that need modifying. If you have 3rd-party extensions (eg. K2) then you should run the respective commands to update the Installer ID in these as well.


Copy over users (but with disabled accounts):
CHANGE the value of @v25_admin_id to the number (in my example "42") to the admin ID of your installer ID.

-- **********************************************************************
-- USERGROUPS: 
-- **********************************************************************
-- Ensure ID (primary key) match up on both systems unless you have 
-- custom usergroups.

-- I did not have to do it this time but shout if you need help


-- **********************************************************************
-- USERS: (but with disabled accounts)
-- **********************************************************************
-- Contrary to recommended practice, I'm moving these guys first so all
-- the objects from the existing site will retain their ownership.  Based
-- on previous migrations, this tends to help not confuse the system.  
-- **********************************************************************

-- Set to your v2.5.x admin ID to NOT migrate as per standard users
SET @v25_admin_id=42;	-- Set this to the ID number of the user in your Joomla 2.5.x

-- Standard Users:
INSERT INTO 
	`v34_db`.`v34_users` ( 
		`id`, `name`, `username`, `email`, `password`, `block`, 
		`sendEmail`, `registerDate`, `lastvisitDate`, 
		`activation`, `params`, `lastResetTime`, `resetCount`, 
		`otpKey`, `otep`, `requireReset`) 
SELECT 
	`id`, `name`, `username`, `email`, `password`, 1, 
	`sendEmail`, `registerDate`, `lastvisitDate`, 
	`activation`, `params`, `lastResetTime`, `resetCount`, 
	'' AS `otpKey`, '' AS `otep`, 0
FROM 
	`v25_db`.`v25_users` 
WHERE 
	`id` <> @v25_admin_id; 


-- To import any new users on golive date
-- -- same as above but change the last line to "WHERE `id` > ####" 
-- -- where #### is the last ID in the new v34 system.
-- -- NB: Don't forget to activate them at GoLive time.


-- *********************************************************************
-- USERGROUP MAPPING
-- *********************************************************************
-- Note-to-self: Delete rows other than the admin ID
-- DELETE FROM `v34_db`.`v34_user_usergroup_map` WHERE `user_id` <> @v25_admin_id; 
-- *********************************************************************

INSERT INTO 
	`v34_db`.`v34_user_usergroup_map` ( 
		`user_id`, `group_id`) 
SELECT 
	`user_id`, `group_id`
FROM 
	`v25_db`.`v25_user_usergroup_map`
WHERE 
	`user_id` <> @v25_admin_id; 

Joomla Categories
Use method #1 if you already have third-party demo content in the database (eg. Quickstarts), use method #2 if you don't have any categories except the core Joomla ones.

-- *********************************************************************
-- CATEGORIES
-- *********************************************************************
-- Much tougher to do than one would think, especially if you have sample 
-- content already in the new system.  The thing to watch out for is
-- associating the categories with respect to the assets table.
-- *********************************************************************
-- METHOD #1- DOES NOT MAINTAIN V25 CATEGORY IDS: setup these categories 
-- using the the Joomla admin interface Web-GUI to add them.  Ensure the 
-- aliases are the same in both systems.  This is a more stable option.
-- *********************************************************************




-- *********************************************************************
-- METHOD #2- MAINTAINS V25 CATEGORY IDS: This will fail if you have any
-- conflicting categories already in the database.  If you only have the 
-- ones from an Out-of-the-box Joomla! CMS then this is what I use: 
-- -- Copy and replace the below script per category
-- -- this example is for one "uncategorized content" category
-- *********************************************************************

SET @uncategorisedCategoryID_new = (
	SELECT id 
	FROM `v34_db`.`v34_categories` 
	WHERE extension='com_content' 
	      AND alias='uncategorised');
SET @uncategorisedCategoryID_old = (
	SELECT id 
	FROM `v25_db`.`v25_categories` 
	WHERE extension='com_content' 
	      AND alias='uncategorised');

UPDATE  `v34_db`.`v34_categories` 
SET `catid` = @uncategorisedCategoryID_new 
WHERE `catid` = @uncategorisedCategoryID_old;
UPDATE  `v34_db`.`v34_content` 
SET `catid` = @uncategorisedCategoryID_new 
WHERE `catid` = @uncategorisedCategoryID_old;


Joomla Content

-- *********************************************************************
-- CONTENT
-- *********************************************************************
-- Should be a question of inserting then associating the categories and  
-- inserting into the assets table per article.  We are going to put a 
-- marker ":|joe|:" and append the old ID for later use.
-- *********************************************************************

-- Assets
SET @maxAssetContentID = (SELECT COUNT(*) FROM `v34_db`.`v34_assets` WHERE `name` LIKE 'com_content.article.%');
SET @nextAssetContentID = @maxAssetContentID;
SET @assetParentID = (SELECT `id` FROM `v34_db`.`v34_assets` WHERE `name` LIKE 'com_content.category.%' AND `title` = 'Uncategorised' LIMIT 0,1);

INSERT INTO 
	`v34_db`.`v34_assets` ( 
		`parent_id`, `lft`, `rgt`, `level`, 
		`name`, 
		`title`, `rules`) 
SELECT 
	@assetParentID, 
	a.`lft`, a.`rgt`, a.`level`, 
	CONCAT('com_content.article.', @nextAssetContentID:=@nextAssetContentID+1, ':|joe|:', c.`id`) AS new_name, 
	a.`title`, a.`rules`
FROM 
	`v25_db`.`v25_assets` a
	INNER JOIN `v25_db`.`v25_content` c ON c.`asset_id`=a.`id`
WHERE 
	a.`name` LIKE 'com_content.article.%';


-- Articles
INSERT INTO 
	`v34_db`.`v34_content` ( 
		`id`, `asset_id`, `title`, `alias`, `introtext`, 
		`fulltext`, `state`, `catid`, `created`, `created_by`, 
		`created_by_alias`, `modified`, `modified_by`, 
		`publish_up`, `publish_down`, `images`, `urls`, 
		`attribs`, `version`, `ordering`, `metakey`, `metadesc`, 
		`access`, `hits`, `metadata`, `featured`, `language`, 
		`xreference`) 
SELECT 
	a.`id`, 
	(
		SELECT x.`id` 
		FROM `v34_db`.`v34_assets` x 
		WHERE x.`name` LIKE 'com_content.article.%' 
			AND x.`name` LIKE CONCAT('%', ':|joe|:', a.`id`)
	) as asset_id, 
	a.`title`, a.`alias`, a.`introtext`, 
	a.`fulltext`, a.`state`, a.`catid`, a.`created`, a.`created_by`, 
	a.`created_by_alias`, a.`modified`, a.`modified_by`, 
	a.`publish_up`, a.`publish_down`, a.`images`, a.`urls`, 
	a.`attribs`, a.`version`, a.`ordering`, a.`metakey`, a.`metadesc`, 
	a.`access`, a.`hits`, a.`metadata`, a.`featured`, a.`language`, 
	a.`xreference`
FROM 
	`v25_db`.`v25_content` a;

-- Now associate new category IDs to new articles
UPDATE `v34_db`.`v34_content` c1
	JOIN `v25_db`.`v25_content` c2 ON c2.`introtext`=c1.`introtext`
	JOIN `v25_db`.`v25_categories` t2 ON c2.`catid`=t2.`id`
	JOIN `v34_db`.`v34_categories` t1 ON t2.`alias`=t1.`alias` 
		AND t1.`path`=t2.`path` 
		AND t1.`extension`='com_content' 
		AND t2.`extension`='com_content'
SET 
	c1.`catid`=t1.`id`;


-- Joe-Code: LIST Rows to be affected (for test purposes)
-- SELECT SUBSTRING(a.`name`, 1, INSTR(a.`name`, ':|joe')-1 ) 
-- FROM `v34_db`.`v34_assets` a 
-- WHERE a.`name` LIKE '%:|joe|:%'

-- Joe-Code: Remove comments
UPDATE `v34_db`.`v34_assets` a
SET a.`name`=SUBSTRING(a.`name`, 1, INSTR(a.`name`, ':|joe')-1 )
WHERE a.`name` LIKE '%:|joe|:%';



Weblinks
As helpful as they'll ever be. Still, I have a few I might want to keep, might as well migrate all of them:
-- *********************************************************************
-- Weblinks
-- *********************************************************************
-- First let us copy over all the weblinks, we will deal with categories
-- and assets afterwards:
-- *********************************************************************

-- Clear the weblinks table
DELETE FROM `v34_db`.`v34_weblinks`;
ALTER TABLE `v34_db`.`v34_weblinks` AUTO_INCREMENT=1;

-- Copy over the weblinks
INSERT INTO 
	`v34_db`.`v34_weblinks` ( 
		`id`, `catid`, `title`, `alias`, `url`, `description`, 
		`hits`, `state`, `ordering`, `access`, `params`, 
		`language`, `created`, `created_by`, `created_by_alias`, 
		`modified`, `modified_by`, `metakey`, `metadesc`, 
		`metadata`, `featured`, `xreference`) 
SELECT 
	a.`id`, a.`catid`, a.`title`, a.`alias`, a.`url`, 
	CONCAT(a.`description`, `:|joe|:`, a.`catid`) AS `description`, 
	a.`hits`, a.`state`, a.`ordering`, a.`access`, a.`params`, 
	a.`language`, a.`created`, a.`created_by`, a.`created_by_alias`, 
	a.`modified`, a.`modified_by`, a.`metakey`, a.`metadesc`, 
	a.`metadata`, a.`featured`, a.`xreference`
FROM 
	`v25_db`.`v25_weblinks` a;

-- Joe-Code: Remove comments
-- UPDATE `v34_db`.`v34_weblinks` a
-- SET a.`description`=SUBSTRING(a.`description`, 1, INSTR(a.`description`, ':|joe')-1 )
-- WHERE a.`description` LIKE '%:|joe|:%';


-- *********************************************************************
-- Weblink Categories
-- *********************************************************************
-- METHOD #1 - Use the GUI to create your weblink categories: 
-- Adding the weblinks using the Joomla admin interface and then 
-- updating the database with the correct IDs is easier than the script.  
-- Use this if there aren't many to do.  In this example, I am applying 
-- this to the "uncategorized" category.
-- *********************************************************************

SET @uncategorisedCategoryID_new = (
	SELECT id 
	FROM `v34_db`.`v34_categories` 
	WHERE extension='com_weblinks' 
	      AND alias='uncategorised');
SET @uncategorisedCategoryID_old = (
	SELECT id 
	FROM `v25_db`.`v25_categories` 
	WHERE extension='com_weblinks' 
	      AND alias='uncategorised');

UPDATE  `v34_db`.`v34_weblinks` 
SET `catid` = @uncategorisedCategoryID_new 
WHERE `catid` = @uncategorisedCategoryID_old;


-- *********************************************************************
-- Weblink Categories
-- *********************************************************************
-- METHOD #2: The challenge here is that we need the weblink categories 
-- inserted as core joomla categories and their respective asset entries.
-- *********************************************************************

-- Assets
SET @maxAssetContentID = (
	SELECT COUNT(*) 
	FROM `v34_db`.`v34_assets` 
	WHERE `name` LIKE 'com_weblinks.category.%');
SET @nextAssetContentID = @maxAssetContentID;
SET @assetParentID = (
	SELECT `id` 
	FROM `v34_db`.`v34_assets` 
	WHERE `name` LIKE 'com_weblinks.category.%' 
		AND `title` = 'Uncategorised');

INSERT INTO 
	`v34_db`.`v34_assets` ( 
		`parent_id`, `lft`, `rgt`, 
		`level`, `name`, `title`, `rules`) 
SELECT 
	@assetParentID, 
	a.`lft`, a.`rgt`, a.`level`, 
	CONCAT('com_weblinks.category.', @nextAssetContentID:=@nextAssetContentID+1, ':|joe|:', c.`id`,':|joe|:', a.`name`) AS new_name, 
	a.`title`, a.`rules`
FROM 
	`v25_db`.`v25_assets` a
	INNER JOIN `v25_db`.`v25_categories` c ON c.asset_id=a.id
WHERE 
	a.`name` LIKE 'com_weblinks.category.%';


-- Categories
SET @assetParentID = (
	SELECT `id` 
	FROM `v34_db`.`v34_assets` 
	WHERE `name` LIKE 'com_weblinks.category%' 
		AND `title` = 'Uncategorised' 
	LIMIT 0,1);
INSERT INTO 
	`v34_db`.`v34_categories` ( 
		`asset_id`, `parent_id`,
		`level`, `path`, `extension`, `title`
		`alias`, `note`, `description`, `published`
		`access`, `params`, `metadesc`, `metakey`
		`metadata`, `created_user_id`, `created_time`, 
		`modified_user_id`, `modified_time`, `hits`, `language`) 
SELECT 
	a.`asset_id`, 
	@assetParentID, 
	a.`level`, a.`path`, a.`extension`, a.`title`,
	a.`alias`, a.`note`, a.`description`, a.`published`,
	a.`access`, a.`params`, a.`metadesc`, a.`metakey`,
	a.`metadata`, a.`created_user_id`, a.`created_time`, 
	a.`modified_user_id`, a.`modified_time`, a.`hits`, a.`language` 
FROM 
	`v25_db`.`v25_categories` a
	INNER JOIN `v25_db`.`v25_assets` a2 ON a2.id=a.asset_id
	INNER JOIN `v34_db`.`v34_assets` b ON (
		SELECT 	SUBSTRING_INDEX(SUBSTRING_INDEX(b.`name`, ':|joe|:', -2),':|joe|:', 1) 
		FROM  `v34_db`.`v34_assets` b 
		WHERE  b.`name` LIKE 'com_weblinks.category.%:|joe%'
	) = a.id
WHERE 
	a2.`name` LIKE 'com_weblinks.category.%';
Pre-Release Go-Live Notes:
The following is to enable any activated users on the v2.5 system so that they can log in to the new system.
-- TO ACTIVATE USERS (do NOT do this until after you have finished the migration): 
UPDATE `v34_db`.`v34_users` a, `jbuzzer_joellipman_live`.`jdlv2_users` b SET a.`block`=b.`block` WHERE a.`id`=b.`id`;

-- Tip: order by created_user_id in both ascending/descending to ensure any new user IDs

-- Any deletions should be accompanied by reset of auto-increment
-- eg. ALTER TABLE `v34_content` AUTO_INCREMENT = 1


JComments
Obviously only do this if you have jComments installed. If I ever get a task to migrate a website with K2, I'll update this article.
-- *********************************************************************
-- JComments 3.0 for Joomla 3.x
-- *********************************************************************
-- A third-party product which is integrated to many delivered templates
-- that use the Joomla core content components.
-- *********************************************************************
-- Our task here is to insert the new comments, correctly associated to
-- their respective articles and users.  Most of the users as per 
-- previous steps will match up, anonymous users (non-registered members)
-- will be migrated without association (retain UserID=0). The article IDs 
-- should also match up.
-- *********************************************************************
-- This script assumes you have no jComments in the new system (why 
-- should you have new ones?  This is a site migration not an upgrade).
-- [Optional: Clear jComments and reset table index with DELETE and ALTER]
-- NOTE: One-line inserts only apply where the column count is the same.
-- *********************************************************************

-- Comments
DELETE FROM `v34_db`.`v34_jcomments`;
ALTER TABLE `v34_db`.`v34_jcomments` AUTO_INCREMENT=1;
INSERT INTO 
	`v34_db`.`v34_comments` ( 
		`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`, `deleted`, `subscribe`, `source`
		`source_id`, `checked_out`, `checked_out_time`, `editor`
		) 
SELECT 
	a.`id`, a.`parent`, a.`thread_id`, 
	a.`path`, a.`level`, a.`object_id`, 
	a.`object_group`, a.`object_params`, a.`lang`, 
	a.`userid`, a.`name`, a.`username`, 
	a.`email`, a.`homepage`, a.`title`, a.`comment`
	a.`ip`, a.`date`, a.`isgood`, a.`ispoor`
	a.`published`, a.`deleted`, a.`subscribe`, a.`source`
	a.`source_id`, a.`checked_out`, a.`checked_out_time`, a.`editor`
FROM 
	`v25_db`.`v25_comments` a

-- Blacklist
DELETE FROM `v34_db`.`v34_jcomments_blacklist`;
ALTER TABLE `v34_db`.`v34_jcomments_blacklist` AUTO_INCREMENT=1;
INSERT INTO 
	`v34_db`.`v34_jcomments_blacklist` ( 
		`id`, `ip`, `userid`, 
		`created`, `created_by`, 
		`expire`, `reason`, `notes`, 
		`editor`
	) 
SELECT 
	a.`id`, a.`ip`, a.`userid`, 
	a.`created`, a.`created_by`, 
	a.`expire`, a.`reason`, a.`notes`, 
	a.`editor`
FROM 
	`v25_db`.`v25_jcomments_blacklist` a

-- Custom BB Codes
DELETE FROM `v34_db`.`v34_jcomments_custom_bbcodes`;
ALTER TABLE `v34_db`.`v34_jcomments_custom_bbcodes` AUTO_INCREMENT=1;
INSERT INTO `v34_db`.`v34_jcomments_custom_bbcodes` 
	SELECT * FROM `v25_db`.`v25_jcomments_custom_bbcodes`;

DELETE FROM `v34_db`.`v34_jcomments_objects`;
ALTER TABLE `v34_db`.`v34_jcomments_objects` AUTO_INCREMENT=1;
INSERT INTO 
	`v34_db`.`v34_jcomments_objects` ( 
		`id`, `object_id`, `object_group`, 
		`lang`, `title`, 
		`link`, `access`, `userid`, 
		`expired`, `modified`
	) 
SELECT 
	a.`id`, a.`object_id`, a.`object_group`, 
	a.`lang`, a.`title`, 
	a.`link`, a.`access`, a.`userid`, 
	a.`expired`, a.`modified`
FROM 
	`v25_db`.`v25_jcomments_objects` a


-- INSERT INTO `v34_db`.`v34_jcomments_reports` 
--	SELECT * FROM `v25_db`.`v25_jcomments_reports`;

DELETE FROM `v34_db`.`v34_jcomments_settings`;
ALTER TABLE `v34_db`.`v34_jcomments_settings` AUTO_INCREMENT=1;
INSERT INTO `v34_db`.`v34_jcomments_settings` 
	SELECT * FROM `v25_db`.`v25_jcomments_settings`;

DELETE FROM `v34_db`.`v34_jcomments_subscriptions`;
ALTER TABLE `v34_db`.`v34_jcomments_subscriptions` AUTO_INCREMENT=1;
INSERT INTO 
	`v34_db`.`v34_jcomments_subscriptions` ( 
		`id`, `object_id`, `object_group`, 
		`lang`, `userid`, 
		`name`, `email`, `hash`, 
		`published`, `source`
	) 
SELECT 
	a.`id`, a.`object_id`, a.`object_group`, 
	a.`lang`, a.`userid`, 
	a.`name`, a.`email`, a.`hash`, 
	a.`published`, a.`source`
FROM 
	`v25_db`.`v25_jcomments_subscriptions` a

-- INSERT INTO `v34_db`.`v34_jcomments_version` SELECT * FROM `v25_db`.`v25_jcomments_version`;

DELETE FROM `v34_db`.`v34_jcomments_votes`;
ALTER TABLE `v34_db`.`v34_jcomments_votes` AUTO_INCREMENT=1;
INSERT INTO 
	`v34_db`.`v34_jcomments_votes` ( 
		`id`, `commentid`, `userid`, 
		`ip`, `date`, 
		`value`
	) 
SELECT 
	`id`, `commentid`, `userid`, 
	`ip`, `date`, 
	`value`
FROM 
	`v25_db`.`v25_jcomments_votes` a

Quick string replacements
These are merely for reference for myself. Their purpose are for quick tweaks to the database values after a migration.

-- Replace stringtofind with the string you want to find
-- Replace stringtoreplace with the string you want to replace with

-- REPLACE FROM A STARTING POINT
-- Read-Only (see changes to commit)
SELECT	a.`fieldtochange`, SUBSTRING(a.`fieldtochange`, INSTR(a.`fieldtochange`, 'stringtofind') ) 
FROM	`v34_mytablename` a 
WHERE 	a.`fieldtochange` LIKE '%stringtofind%'

-- Write-Mode (commit changes)
UPDATE	`v34_mytablename` a 
SET	a.`fieldtochange`= SUBSTRING(a.`fieldtochange`, INSTR(a.`fieldtochange`, 'stringtofind') ) 
WHERE 	a.`fieldtochange` LIKE '%stringtofind%'


-- REPLACE ANY OCCURRENCE
-- Read-Only (see changes to commit)
SELECT 	a.`fieldtochange`, REPLACE(a.`fieldtochange`, 'stringtofind',  'stringtoreplace') 
FROM 	`v34_mytablename` a 
WHERE	a.`fieldtochange` LIKE '%stringtofind%'

-- Write-Mode (commit changes)
UPDATE	`v34_mytablename` a 
SET	a.`fieldtochange` = REPLACE(a.`fieldtochange`, 'stringtofind',  'stringtoreplace') 
WHERE 	a.`fieldtochange` LIKE '%stringtofind%'

Watch out for any recursive loops.


Disclaimer:
As I use this on more websites, I will update this article accordingly. At the time of print, I have only done one website with the above instructions, mine.

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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.