Thursday, May 17, 2012

Migrating from Joomla! 1.5 to 1.6

So this is fun. We've waited and waited and Joomla 1.6 is now stable... Exciting because this is not a simple 1.5.21 to 1.5.22 upgrade. But don't believe the drama across the web, the system introduces only a few new fundamental improvements (particularly Access Control and Groups) which actually only means some minor database alterations.

I've googled and yahood but still can't find a good way to upgrade my site from Joomla version 1.5 to 1.6 so as usual I find myself writing the first migration script. Why use a script? Well jUpgrade didn't work for me. This is how to manually migrate using a MySQL database management tool or PhpMyAdmin. I'm not too bothered about my own personal site, it's just the silly number of client websites I have to upgrade.

Before anyone posts the suggestion which they clearly copied and pasted from another site, I tried jUpgrade and this failed. Basically I've tried all major browsers in running the extension, and all that happens is that the jUpgrade starts and says " Preparing...". The sites I need to upgrade have third-party extensions unlike the how-to video...

DO NOT RUN THE BELOW -- IT IS STILL UNDERGOING TESTS!

This is to help me migrate Joomla 1.5 sites to Joomla 1.6 automatically. I will be needing the script to support several 3rd-party extensions as well.

DISCLAIMER:

  • I do not work for Joomla!
  • This script is for my own use.
  • Joomla! are in no way liable for this script.
  • You can copy this script as long as you specify a link to its source.
  • You can use this script as long as you don't hold me responsible for the results.
  • If you don't understand what this script is doing, you shouldn't be running it. Please ask someone who does.


-- IMPORTANT NOTES (to be included in SQL script):
-- -- The script below is to migrate your existing Joomla! 1.5 database
-- -- to a FRESH install of Joomla! 1.6.0
-- -- You should have both sites up and running alongside each other.

-- -- The instructions below uses 2 databases: LIVE and TEST
-- -- Do not run this if you only have 1 database available!


-- REQUIRED:
-- -- To change the database names used in the below script to the ones you use!!!
-- -- A minimum of 2 databases.  The original and the one to migrate to.
-- -- A login account (mysql user) with most privileges on both databases.


-- RECOMMENDED SETUP FOR TESTING THIS SCRIPT:
-- -- Live = The live and original version of the website (Joomla! 1.5.x)
-- -- Dev1 = Copy of LIVE version (Joomla! 1.5.x) -> for SELECT statements.
-- -- Dev2 = Joomla! 1.6.0 with all LIVE data committed through GUI.
-- -- Dev3 = Joomla! 1.6.0 with SAMPLE data installed
-- -- Dev4 = Joomla! 1.6.0 with NO SAMPLE data -> Used to reset Dev5
-- -- Dev5 = Joomla! 1.6.0 with NO SAMPLE data -> for INSERT statements. (QA)
-- -- Upgrade = Empty folder and database.  Should be a copy of Dev5 on successful migration.


-- MINIMAL SETUP REQUIRED FOR USING THIS SCRIPT:
-- -- Live = The live and original version of the website (Joomla! 1.5.x)
-- -- Upgrade = Fresh install of Joomla! 1.6.0 with NO SAMPLE data subject to this script.


-- TABLE OF CONTENTS : These are the basic Joomla 1.5 tables
-- I. Help on using the queries below
-- -- 1. replace all database names in the scripts below
-- -- 2. checking before you commit changes

-- II. Copy content from the old database to the new database and tweak:
-- -- 1. setting some variables
-- -- 2. jos_banner -> jos_banners
-- -- 3. jos_bannerclient -> jos_banner_clients
-- -- 4. jos_bannertrack -> jos_banner_tracks
-- -- 5. jos_categories
-- -- 6. jos_components -> jos_extensions
-- -- 7. jos_contact_details
-- -- 8. jos_content
-- -- 9. jos_content_frontpage
-- -- 10. jos_content_rating
-- -- 11. jos_core_log_items, jos_core_log_searches -> jos_core_log_searches
-- -- 12. jos_menu
-- -- 13. jos_menu_types
-- -- 14. jos_messages
-- -- 15. jos_messages_cfg
-- -- 16. jos_modules
-- -- 17. jos_modules_menu
-- -- 18. jos_newsfeeds
-- -- 19. jos_plugins -> jos_extensions
-- -- 20. 20. jos_users, jos_core_acl_groups_aro_map, jos_core_acl_aro -> jos_user_usergroup_map, jos_users
-- -- 21. jos_weblinks
-- -- 22. updating keys

-- III. Third-party Extensions
-- -- 1. jos_comments # for jComments
-- -- 2. jos_rokdownloads # for Rocket Theme rokdownloads



-- READY?

-- *****************************************************************************
--
-- BIG NOTE: REPLACE mydb_livecopy with name of OLD database
-- BIG NOTE: REPLACE mydb_upgrade with name of NEW database
--
-- *****************************************************************************

-- -----------------------------------------------------------------------------
-- I. Help on using the queries below
-- -----------------------------------------------------------------------------

--	 There are a few notes about running the scripts.

--	 A new table in Joomla 1.6 is the `jos_assets` which seems to list
--       each article, banner, category, contact, newsfeed, weblink.  This is
--       why each snippet consists of more than one MySQL query.


-- -----------------------------------------------------------------------------
-- -- 1. replace all database names in the scripts below
-- -----------------------------------------------------------------------------

--       Yeh well u've been warned BACKUP BACKUP BACKUP.

--       I have several databases and websites setup with exact copies of the 
--       data so I can risk this one not working.  You need as a minimum, at 
--       least 2 databases to use the queries in this script (Live and Test).

--	 -- Change "mydb_livecopy" to the existing & current database (J!1.5)
--	 -- Change "mydb_upgrade" to the name of the new database (J!1.6)


-- -----------------------------------------------------------------------------
-- -- 2. checking before you commit changes
-- -----------------------------------------------------------------------------

--       If you select the part of each expression from the SELECT and run these
--       to see what results are returned, it is reading only and not making any
--       changes.  It will show you what data the query is planning to migrate.


-- -----------------------------------------------------------------------------
-- II. 1. Declare some variables
-- -----------------------------------------------------------------------------

--       A bit obsolete as we'll address each variable and update at the end.
--	SET @admin_user_id_old_website=62;
--	SET @admin_user_id_new_website=42;


-- -----------------------------------------------------------------------------
-- II. 2. jos_banner to jos_banners
-- -----------------------------------------------------------------------------

-- For BANNERS, we're going to affect 3 tables in the new database:
--	jos_assets 
--	jos_categories
--	jos_banners

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT BANNER CATEGORIES FROM J15 AND INSERT AS ASSETS IN J16

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastcatid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastcatid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);
SET @new_jos_banners_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_assets WHERE name='com_banners');

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	@new_jos_banners_parent_id, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 2,
	CONCAT('com_banners.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|: '),
	'{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_banner';

-- ::::::::: NOW INSERT BANNER CATEGORIES FROM J15 AS CATEGORIES IN J16

SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_content' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);
SET @new_jos_banners_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_categories WHERE extension='system');

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language)
SELECT
	@new_jos_banners_parent_id, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 1, @new_jos_categories_extension_alias,
	'com_banners', title, alias, CONCAT('Import from J15. PreviousID=catid', id),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"target":"","image":""}', '{"page_title":"","author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_banner';

-- ::::::::: IMPORT ALL BANNERS USING ASSET_ID AND CAT_ID CREATED

INSERT INTO
	mydb_upgrade.jos_banners (
	id, cid, type, name, alias, imptotal, impmade, clicks, clickurl, state, catid,
	description, custombannercode, sticky, ordering, params, 
	track_clicks, track_impressions, publish_up, publish_down, created, language)
SELECT
	bid, cid, type, name, alias, imptotal, impmade, clicks, clickurl, 1, catid,
	description, custombannercode, sticky, ordering,
	IF(params='', '', CONCAT('{"', REPLACE(REPLACE(params, CHAR(10), '","'), '=', '":"'), '"}')), 
	0, 0, publish_up, publish_down, date, '*'
FROM
	mydb_livecopy.jos_banner;

-- ::::::::: UPDATE FOREIGN KEYS: jos_categories.asset_id

UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets b
SET a.asset_id=b.id WHERE b.name LIKE 'com_banners.category.%'
AND b.title LIKE '% :|joes|%'
AND SUBSTR( b.title, LOCATE(' :|joes|', b.title)+8, (LOCATE('|: ', b.title)-(LOCATE(' :|joes|', b.title)+8)) ) = SUBSTR( a.note, LOCATE(' PreviousID=catid', a.note) + 17 );

-- ::::::::: REMOVE SCRIPTING NOTES: jos_assets.name

UPDATE mydb_upgrade.jos_assets b, mydb_upgrade.jos_categories a
SET b.title=TRIM(SUBSTR(b.title, 1, LOCATE(' :|joes|', b.title))), 
b.name=CONCAT('com_banners.category.', a.id)
WHERE b.title LIKE '% :|joes|%' AND b.id=a.asset_id;

-- ::::::::: ASSOCIATE CATEGORY IDS: jos_banners.catid
UPDATE mydb_upgrade.jos_categories a,	mydb_upgrade.jos_banners b
SET b.catid=a.id WHERE b.catid=SUBSTR( a.note, LOCATE('. PreviousID=catid', a.note)+18)
AND SUBSTR( a.note, LOCATE('. PreviousID=', a.note)+13)<>'';

-- ::::::::: ASSOCIATE UNCATEGORISED CATEGORY IDS: jos_banners.catid
SET @new_jos_banners_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_categories WHERE extension='com_banners');
UPDATE mydb_upgrade.jos_banners a, mydb_livecopy.jos_categories b
SET a.catid=@new_jos_banners_parent_id WHERE 
a.catid NOT IN (SELECT id FROM mydb_livecopy.jos_categories);

-- ::::::::: OPTIONAL: Remove my notes from the note field (nice and clean)
-- UPDATE mydb_upgrade.jos_categories SET note='' WHERE note LIKE 'Import from J15. Pre%';
-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

-- -----------------------------------------------------------------------------
-- II. 3. jos_bannerclient to jos_banner_clients
-- -----------------------------------------------------------------------------

INSERT INTO mydb_upgrade.jos_banner_clients (
	id, name, contact, email, extrainfo, checked_out, checked_out_time, 
	purchase_type, track_clicks, track_impressions)
SELECT cid, name, contact, email, extrainfo, 0, 0, 0, 0, 0
FROM mydb_livecopy.jos_bannerclient;


-- -----------------------------------------------------------------------------
-- II. 4. jos_bannertrack to jos_banner_tracks
-- -----------------------------------------------------------------------------

INSERT INTO mydb_upgrade.jos_banner_tracks (track_date, track_type, banner_id)
SELECT track_date, track_type, banner_id
FROM mydb_livecopy.jos_bannertrack;


-- -----------------------------------------------------------------------------
-- II. 5. jos_categories
-- -----------------------------------------------------------------------------

-- NOTE: Categories in Joomla 1.5 have no parent category and sections do not 
--       exist in Joomla 1.6.0

--	 1. Import sections as new categories 
--	 2. Import categories from Joomla 1.5
--	 3. Update Joomla 1.6 with new parent_id (retrieve section id)

--	 note-to-self: don't import categories that are for others (eg. com_banners)?
--	 J15 sections only exist for content?

-- For CATEGORIES, we're going to affect 2 tables in the new database:
--	jos_assets 
--	jos_categories
-- then update the foreign keys

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT SECTIONS FROM J1.5 AND INSERT AS ASSETS IN J16

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastcatid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastcatid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);
SET @new_jos_assets_id_parent=(
	SELECT MIN(id) FROM mydb_upgrade.jos_assets WHERE name='com_content');
INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	@new_jos_assets_id_parent, 
	@new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 2,
	CONCAT('com_content.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|: '),
	'{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}'
FROM
	mydb_livecopy.jos_sections;

-- ::::::::: NOW INSERT THESE SECTIONS AS CATEGORIES IN J16

SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_content' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language
	)
SELECT
	1, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 1, alias,
	'com_content', title, alias, CONCAT('Import from J15. PreviousID=', id),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"target":"","image":""}', '{"page_title":"","author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_sections;

-- ::::::::: UPDATE FOREIGN KEYS FOR J16: jos_categories.asset_id

UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets b
SET a.asset_id=b.id WHERE b.name LIKE 'com_content.category.%'
AND b.title LIKE '% :|joes|%'
AND SUBSTR( b.title, LOCATE(' :|joes|', b.title)+8, (LOCATE('|: ', b.title)-(LOCATE(' :|joes|', b.title)+8)) ) = SUBSTR( a.note, LOCATE(' PreviousID=', a.note) + 12 );

-- ::::::::: REMOVE SCRIPTING NOTES: jos_assets.name

UPDATE mydb_upgrade.jos_assets b, mydb_upgrade.jos_categories a
SET b.title=TRIM(SUBSTR(b.title, 1, LOCATE(' :|joes|', b.title))), 
b.name=CONCAT('com_content.category.', a.id)
WHERE b.title LIKE '% :|joes|%' AND b.id=a.asset_id;

-- ::::::::: IMPORT CATEGORIES FROM J15 AND INSERT AS ASSETS IN J16

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastcatid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastcatid DESC LIMIT 0,1);
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	0, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 3,
	CONCAT('com_content.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|: '),
	'{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section>0;

-- ::::::::: NOW INSERT CATEGORIES FROM J15 AS CATEGORIES IN J16

SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_content' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language)
SELECT
	0, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 2, @new_jos_categories_extension_alias,
	'com_content', title, alias, CONCAT('Import from J15. PreviousID=catid', id, '. SectionID=', section),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"target":"","image":""}', '{"page_title":"","author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section>0;

-- ::::::::: UPDATE FOREIGN KEYS FOR JOOMLA16: jos_categories.asset_id

UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets b
SET a.asset_id=b.id WHERE b.name LIKE 'com_content.category.%'
AND b.title LIKE '% :|joes|%'
AND SUBSTR( b.title, LOCATE(' :|joes|', b.title)+8, (LOCATE('|: ', b.title)-(LOCATE(' :|joes|', b.title)+8)) ) = SUBSTR( a.note, LOCATE(' PreviousID=catid', a.note) + 17, (LOCATE('. SectionID=', a.note)-(LOCATE(' PreviousID=catid', a.note) + 17)));

-- ::::::::: REMOVE SCRIPTING NOTES: jos_assets.name

UPDATE mydb_upgrade.jos_assets b, mydb_upgrade.jos_categories a
SET b.title=TRIM(SUBSTR(b.title, 1, LOCATE(' :|joes|', b.title))), 
b.name=CONCAT('com_content.category.', a.id)
WHERE b.title LIKE '% :|joes|%' AND b.id=a.asset_id;

-- ::::::::: CORRECT CATEGORY PARENT IDS BASED ON SECTIONS

UPDATE mydb_upgrade.jos_categories a,	mydb_upgrade.jos_categories b 
SET b.parent_id=a.id, b.path=CONCAT(a.alias, '/', b.alias) WHERE 
SUBSTR( b.note, LOCATE('. SectionID=', b.note)+12)=SUBSTR( a.note, LOCATE('. PreviousID=', a.note)+13)
AND SUBSTR( a.note, LOCATE('. PreviousID=', a.note)+13)<>'';

-- ::::::::: CORRECT ASSET PARENT IDS BASED ON ASSETS
UPDATE mydb_upgrade.jos_assets a, mydb_upgrade.jos_assets b, 
	mydb_upgrade.jos_categories c, mydb_upgrade.jos_categories d 
SET a.parent_id=b.id WHERE a.id=c.asset_id AND c.parent_id=d.id
AND d.asset_id=b.id AND a.level=3;

-- ::::::::: OPTIONAL: Remove my notes from the note field (nice and clean)
-- UPDATE mydb_upgrade.jos_categories SET note='' WHERE note LIKE 'Import from J15. Previous%';
-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


-- -----------------------------------------------------------------------------
-- II. 6. jos_components -> jos_extensions
-- -----------------------------------------------------------------------------
--
-- The default tables are installed, see "III. third-party extensions" below
--


-- -----------------------------------------------------------------------------
-- II. 7. jos_contact_details
-- -----------------------------------------------------------------------------

-- For CONTACT DETAILS, we're going to affect 3 tables in the new database:
--	jos_assets 
--	jos_categories
--	jos_contact_details
-- then update the foreign keys

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT CONTACT CATEGORIES FROM J15 AND INSERT AS ASSETS IN J16

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastcatid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastcatid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);
SET @new_jos_contacts_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_assets WHERE name='com_contact');

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	@new_jos_contacts_parent_id, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 2,
	CONCAT('com_contact.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|: '),
	'{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_contact_details';

-- ::::::::: NOW INSERT CONTACT CATEGORIES FROM J15 AS CATEGORIES IN J16

SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_content' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);
SET @new_jos_contacts_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_categories WHERE extension='system');

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language)
SELECT
	@new_jos_contacts_parent_id, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 1, alias,
	'com_contact', title, alias, CONCAT('Import from J15. PreviousID=catid', id),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"category_layout":"","image":""}', '{"author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_contact_details';

-- ::::::::: IMPORT ALL CONTACTS USING ASSET_ID AND CAT_ID CREATED

INSERT INTO
	mydb_upgrade.jos_contact_details (
	name, alias, con_position, address, suburb, state, country, postcode,
	telephone, fax, misc, image, imagepos, email_to, default_con, published,
	checked_out, checked_out_time, ordering,
	params,
	user_id, catid,
	access,
	mobile, webpage, language, created, created_by, metadata )
SELECT
	name, alias, con_position, address, suburb, state, country, postcode,
	telephone, fax, CONCAT(misc, ' :|joes|', id, '|:'), image, imagepos, 
	email_to, default_con, published, 0, 0, ordering,
	IF(params='', '', CONCAT('{"', REPLACE(REPLACE(params, CHAR(10), '","'), '=', '":"'), '"}')),
	@admin_user_id_old_website, 4,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	mobile, webpage, '*', NOW(), 42, '{"robots":"","rights":""}'
FROM
	mydb_livecopy.jos_contact_details;

-- ::::::::: UPDATE FOREIGN KEYS: jos_categories.asset_id

UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets b
SET a.asset_id=b.id WHERE b.name LIKE 'com_contact.category.%'
AND b.title LIKE '% :|joes|%'
AND SUBSTR(b.title,LOCATE(' :|joes|',b.title)+8,(LOCATE('|: ',b.title)-(LOCATE(' :|joes|', b.title)+8)) ) = SUBSTR( a.note, LOCATE(' PreviousID=catid', a.note) + 17 );

-- ::::::::: REMOVE SCRIPTING NOTES: jos_assets.name

UPDATE mydb_upgrade.jos_assets b, mydb_upgrade.jos_categories a
SET b.title=TRIM(SUBSTR(b.title, 1, LOCATE(' :|joes|', b.title))), 
b.name=CONCAT('com_contact.category.', a.id)
WHERE b.title LIKE '% :|joes|%' AND b.id=a.asset_id;


-- -----------------------------------------------------------------------------
-- II. 8. jos_content
-- -----------------------------------------------------------------------------

-- For CONTENT/ARTICLES, we're going to affect 2 tables in the new database:
--	jos_assets 
--	jos_content
-- then update the foreign keys linking the two

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT ARTICLES FROM J15 AND INSERT AS ASSETS IN J16: jos_assets

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastassetid
	FROM mydb_upgrade.jos_assets WHERE name LIKE 'com_content.article.%'
	ORDER BY lastassetid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	0, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 3,
	CONCAT('com_content.article.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|:'), '{"core.delete":[],"core.edit":[],"core.edit.state":[]}'
FROM
	mydb_livecopy.jos_content;

-- :::::::::  INSERT ARTICLES FROM J15 AS CONTENT IN J16: jos_content
-- NOTE: Reason for inserting IDs is because lots of sites switched to SEO friendly 
--       URLS have the ID in there... prob invalid anyway so look at removing.

INSERT INTO
	mydb_upgrade.jos_content (
	id, asset_id, title, alias, title_alias, introtext, `fulltext`, state, sectionid, mask,
	catid, created, created_by, created_by_alias, modified, modified_by, 
	publish_up, publish_down, images, urls,
	attribs, version, parentid, ordering, metakey, metadesc,
	access, hits, metadata, language)
SELECT
	id, 0, title, alias, title_alias, introtext, `fulltext`, state, sectionid, mask,
	catid, created, created_by, created_by_alias, modified, modified_by, 
	publish_up, publish_down, images, urls,
	IF(attribs='', '', CONCAT('{"', REPLACE(REPLACE(attribs, CHAR(10), '","'), '=', '":"'), '"}')),
	version, 0, ordering, metakey, metadesc,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access, hits, 
	IF(metadata='', '', CONCAT('{"', REPLACE(REPLACE(metadata, CHAR(10), '","'), '=', '":"'), '"}')), '*'
FROM
	mydb_livecopy.jos_content;

-- :::::::::  ASSOCIATE J15 CATEGORIES AND ASSETS: jos_content
-- Also sets section to 0 as J16 sample data does...

UPDATE mydb_upgrade.jos_content a, mydb_livecopy.jos_content b,
	mydb_upgrade.jos_categories c, mydb_livecopy.jos_categories d
SET a.catid=c.id, a.sectionid=0
WHERE a.id=b.id AND c.alias=d.alias 
AND b.catid=d.id AND c.extension='com_content';

UPDATE mydb_upgrade.jos_content a, mydb_upgrade.jos_assets e
SET e.title=a.title, a.asset_id=e.id
WHERE TRIM(CONCAT(a.title, ' :|joes|', a.id, '|:'))=TRIM(e.title);

UPDATE mydb_upgrade.jos_assets a, mydb_upgrade.jos_categories b, mydb_upgrade.jos_content c
SET a.parent_id=b.asset_id WHERE a.id=c.asset_id AND b.id=c.catid;


-- -----------------------------------------------------------------------------
-- II. 9. jos_content_frontpage
-- -----------------------------------------------------------------------------
-- As long as the Article ID was kept intact as per the previous step in this 
-- script, this should be an exact copy in J16.

INSERT INTO mydb_upgrade.jos_content_frontpage (content_id, ordering)
SELECT content_id, ordering
FROM mydb_livecopy.jos_content_frontpage;


-- -----------------------------------------------------------------------------
-- II. 10. jos_content_rating
-- -----------------------------------------------------------------------------
-- As long as the Article ID was kept intact as per the previous step in this 
-- script, this should be an exact copy in J16.

INSERT INTO mydb_upgrade.jos_content_rating (
content_id, rating_sum, rating_count, lastip)
SELECT content_id, rating_sum, rating_count, lastip
FROM mydb_livecopy.jos_content_rating;


-- -----------------------------------------------------------------------------
-- II. 11. jos_core_log_searches -> jos_core_log_searches
-- -----------------------------------------------------------------------------

INSERT INTO mydb_upgrade.jos_core_log_searches (search_term, hits)
SELECT search_term, hits FROM mydb_livecopy.jos_core_log_searches;


-- -----------------------------------------------------------------------------
-- II. 12. jos_menu
-- -----------------------------------------------------------------------------

-- :::::::::  IMPORT J15 MENUS IN J16: jos_menu

-- MENU ITEMS SHOULD BE DONE VIA THE GUI DUE TO THIRD PARTY EXTENSIONS

/**** Possibly get this automatically but need to see it on sites and in use first.
SET @new_jos_menu_id_last=(SELECT MAX(id) FROM mydb_upgrade.jos_menu);
SET @new_jos_menu_lft_last=(SELECT MAX(lft) FROM mydb_upgrade.jos_menu);

INSERT INTO
	mydb_upgrade.jos_menu (
	id, menutype, title, alias, link, type, published, parent_id, level,
	component_id, ordering, browserNav, access, params, lft, rgt, home, 
	language )
SELECT
	@new_jos_menu_id_last:=@new_jos_menu_id_last+1, menutype, name, alias, link, 
	type, published, parent, sublevel+1, 22, ordering, browserNav,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	IF(params='', '', CONCAT('{"', REPLACE(REPLACE(params, CHAR(10), '","'), '=', '":"'), '"}')),
	(@new_jos_menu_lft_last:=@new_jos_menu_lft_last+2),
	(@new_jos_menu_lft_last+1), 0, '*'
FROM
	mydb_livecopy.jos_menu;

UPDATE mydb_upgrade.jos_menu
SET link='index.php?option=com_content&view=featured'
WHERE link='index.php?option=com_content&view=frontpage';
****/

-- -----------------------------------------------------------------------------
-- II. 13. jos_menu_types
-- -----------------------------------------------------------------------------

/*****
INSERT INTO
	mydb_upgrade.jos_menu_types (id, menutype, title, description)
SELECT
	id, menutype, title, description
FROM
	mydb_livecopy.jos_menu_types
WHERE
	id>1;
****/


-- -----------------------------------------------------------------------------
-- II. 14. jos_messages
-- -----------------------------------------------------------------------------
INSERT INTO
	mydb_upgrade.jos_messages (
	message_id, user_id_from, user_id_to, folder_id, date_time, state,
	priority, subject, message)
SELECT
	message_id, user_id_from, user_id_to, folder_id, date_time, state,
	priority, subject, message
FROM
	mydb_livecopy.jos_messages;


-- -----------------------------------------------------------------------------
-- II. 15. jos_messages_cfg
-- -----------------------------------------------------------------------------
INSERT INTO
	mydb_upgrade.jos_messages_cfg (user_id, cfg_name, cfg_value)
SELECT
	user_id, cfg_name, cfg_value
FROM
	mydb_livecopy.jos_messages_cfg;


-- -----------------------------------------------------------------------------
-- II. 16. jos_modules
-- -----------------------------------------------------------------------------
--
-- The default tables are installed, see "III. third-party extensions" below
--


-- -----------------------------------------------------------------------------
-- II. 17. jos_modules_menu -- and skip this for the moment
-- -----------------------------------------------------------------------------
--
-- The default tables are installed, see "III. third-party extensions" below
--


-- -----------------------------------------------------------------------------
-- II. 18. jos_newsfeeds
-- -----------------------------------------------------------------------------

-- For NEWSFEEDS, we're going to affect 3 tables in the new database:
--	jos_assets 
--	jos_categories 
--	jos_newsfeeds
-- then update the foreign keys linking the three

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT NEWSFEED CATEGORIES FROM J15 AND INSERT AS ASSETS IN J16: jos_assets

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastassetid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastassetid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);
SET @new_jos_assets_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_assets WHERE title='com_newsfeeds');

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	@new_jos_assets_parent_id, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 1,
	CONCAT('com_newsfeeds.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|:'), '{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[]}'
FROM
	mydb_livecopy.jos_categories
WHERE
	section='com_newsfeeds';

-- ::::::::: IMPORT NEWSFEED CATEGORIES FROM J15 AND INSERT AS CATEGORIES IN J16: jos_categories
SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_newsfeeds' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);
SET @new_jos_categories_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_categories WHERE title='com_newsfeeds');

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language)
SELECT
	1, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 1, alias,
	'com_newsfeeds', title, alias, CONCAT('Import from J15. PreviousID=catid', id),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"target":"","image":""}', '{"page_title":"","author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_newsfeeds';


UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets e
SET e.title=a.title, a.asset_id=e.id
WHERE TRIM(CONCAT(a.title, ' :|joes|', SUBSTR( a.note, LOCATE('. PreviousID=catid', a.note)+18), '|:'))=TRIM(e.title);



-- :::::::::  INSERT NEWSFEEDS FROM J15 AS NEWSFEEDS IN J16: jos_newsfeeds
SET @admin_user_id_new_website=42;


INSERT INTO
	mydb_upgrade.jos_newsfeeds (
	catid, name, alias, link, filename, published, numarticles,
	cache_time, ordering, rtl,
	access, language,
	params,
	created, created_by, metadata )
SELECT
	catid, name, alias, link, filename, published, numarticles,
	cache_time, ordering, rtl, 1, '*',
	'{"show_feed_image":"","show_feed_description":"","show_item_description":"","feed_character_count":"0"}',
	NOW(), @admin_user_id_new_website, '{"robots":"","rights":""}'
FROM
	mydb_livecopy.jos_newsfeeds;

-- :::::::::  ASSOCIATE J15 CATEGORIES AND NEWSFEEDS: jos_newsfeeds

UPDATE mydb_upgrade.jos_newsfeeds a, mydb_upgrade.jos_categories b
SET a.catid=b.id
WHERE b.note=CONCAT('Import from J15. PreviousID=catid', a.catid)
AND b.extension='com_newsfeeds';


-- -----------------------------------------------------------------------------
-- II. 19. jos_plugins -> jos_extensions
-- -----------------------------------------------------------------------------
--
-- The default tables are installed, see "III. third-party extensions" below
--


-- -----------------------------------------------------------------------------
-- II. 20. jos_users, jos_core_acl_groups_aro_map, jos_core_acl_aro -> jos_user_usergroup_map, jos_users
-- -----------------------------------------------------------------------------

INSERT INTO
	mydb_upgrade.jos_users (
	id, name, username, email, password,
	usertype,
	block, sendEmail, registerDate, lastvisitDate, activation,
	params )
SELECT
	id, name, username, email, password,
	CASE WHEN usertype='Registered' THEN '' ELSE usertype END,
	block, sendEmail, registerDate, lastvisitDate, activation,
	IF(params='', '', CONCAT('{"', REPLACE(REPLACE(params, CHAR(10), '","'), '=', '":"'), '"}'))
FROM
	mydb_livecopy.jos_users;

-- Now add these to the new Joomla 1.6 groups.  Only accepting the ones below:
-- note-to-self: find a way to do these automatically (issue with insert and subquery select from multiple databases).

SET @previous_group_id_sadmin=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Super Administrator' LIMIT 0,1);
SET @previous_group_id_admin=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Administrator' LIMIT 0,1);
SET @previous_group_id_manager=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Manager' LIMIT 0,1);
SET @previous_group_id_publicb=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Public Backend' LIMIT 0,1);
SET @previous_group_id_publisher=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups	WHERE name='Publisher' LIMIT 0,1);
SET @previous_group_id_editor=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Editor' LIMIT 0,1);
SET @previous_group_id_author=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Author' LIMIT 0,1);
SET @previous_group_id_registered=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Registered' LIMIT 0,1);
SET @previous_group_id_publicf=(SELECT id FROM mydb_livecopy.jos_core_acl_aro_groups WHERE name='Public Frontend' LIMIT 0,1);

SET @new_group_id_sadmin=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Super Users' LIMIT 0,1);
SET @new_group_id_admin=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Administrator' LIMIT 0,1);
SET @new_group_id_manager=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Manager' LIMIT 0,1);
SET @new_group_id_public=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Public' LIMIT 0,1);
SET @new_group_id_publisher=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Publisher' LIMIT 0,1);
SET @new_group_id_editor=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Editor' LIMIT 0,1);
SET @new_group_id_author=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Author' LIMIT 0,1);
SET @new_group_id_registered=(SELECT id FROM mydb_upgrade.jos_usergroups WHERE title='Registered' LIMIT 0,1);

INSERT INTO
	mydb_upgrade.jos_user_usergroup_map (
		user_id,
		group_id )
SELECT
	a.aro_id AS user_id,
	CASE
	WHEN a.group_id=@previous_group_id_sadmin THEN @new_group_id_sadmin
	WHEN a.group_id=@previous_group_id_admin THEN @new_group_id_admin
	WHEN a.group_id=@previous_group_id_manager THEN @new_group_id_manager
	WHEN a.group_id=@previous_group_id_publicb THEN @new_group_id_public
	WHEN a.group_id=@previous_group_id_publisher THEN @new_group_id_publisher
	WHEN a.group_id=@previous_group_id_editor THEN @new_group_id_editor
	WHEN a.group_id=@previous_group_id_author THEN @new_group_id_author
	WHEN a.group_id=@previous_group_id_registered THEN @new_group_id_registered
	WHEN a.group_id=@previous_group_id_publicf THEN @new_group_id_public
	END AS group_id
FROM
	mydb_livecopy.jos_core_acl_groups_aro_map a
ORDER BY
	a.aro_id;

-- -----------------------------------------------------------------------------
-- II. 21. jos_weblinks
-- -----------------------------------------------------------------------------

-- For WEBLINKS, we're going to affect 3 tables in the new database:
--	jos_assets 
--	jos_categories 
--	jos_newsfeeds
-- then update the foreign keys linking the three

-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- ::::::::: IMPORT WEBLINKS CATEGORIES FROM J15 AND INSERT AS ASSETS IN J16: jos_assets

SET @new_jos_assets_last_inc=(
	SELECT (SUBSTRING_INDEX(name, '.', -1)*1) AS lastassetid
	FROM mydb_upgrade.jos_assets WHERE name LIKE '%.category.%'
	ORDER BY lastassetid DESC LIMIT 0,1);
SET @new_jos_assets_last_inc=(SELECT IFNULL(@new_jos_assets_last_inc, 0));
SET @new_jos_assets_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_assets);
SET @new_jos_assets_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_assets WHERE title='com_weblinks');

INSERT INTO
	mydb_upgrade.jos_assets (
	parent_id, lft, rgt, level, name, title, rules)
SELECT
	@new_jos_assets_parent_id, @new_jos_assets_id_last_lft:=@new_jos_assets_id_last_lft+2,
	@new_jos_assets_id_last_lft+1, 1,
	CONCAT('com_weblinks.category.', @new_jos_assets_last_inc:=@new_jos_assets_last_inc+1),
	CONCAT(title, ' :|joes|', id, '|:'), '{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[]}'
FROM
	mydb_livecopy.jos_categories
WHERE
	section='com_weblinks';

-- ::::::::: IMPORT WEBLINKS CATEGORIES FROM J15 AND INSERT AS CATEGORIES IN J16: jos_categories
SET @new_jos_categories_extension_alias=(
	SELECT alias FROM mydb_upgrade.jos_categories 
	WHERE extension='com_weblinks' ORDER BY id ASC LIMIT 0,1);
SET @new_jos_categories_id_last_lft=(
	SELECT MAX(lft) FROM mydb_upgrade.jos_categories);
SET @new_jos_categories_parent_id=(
	SELECT MIN(id) FROM mydb_upgrade.jos_categories WHERE title='com_newsfeeds');

INSERT INTO
	mydb_upgrade.jos_categories (
	parent_id, lft, rgt, level, path, extension, title, alias, note, 
	description, published, access, params, metadata, created_user_id,
	created_time, language)
SELECT
	1, @new_jos_categories_id_last_lft:=@new_jos_categories_id_last_lft+2, 
	@new_jos_categories_id_last_lft+1, 1, alias,
	'com_weblinks', title, alias, CONCAT('Import from J15. PreviousID=catid', id),
	description, published,
	CASE WHEN access=0 THEN 1 WHEN access=1 THEN 2 WHEN access=2 THEN 7 END AS access,
	'{"target":"","image":""}', '{"page_title":"","author":"","robots":""}',
	42, NOW(), '*'
FROM
	mydb_livecopy.jos_categories
WHERE
	mydb_livecopy.jos_categories.section='com_weblinks';

UPDATE mydb_upgrade.jos_categories a, mydb_upgrade.jos_assets e
SET e.title=a.title, a.asset_id=e.id
WHERE TRIM(CONCAT(a.title, ' :|joes|', SUBSTR( a.note, LOCATE('. PreviousID=catid', a.note)+18), '|:'))=TRIM(e.title);



-- :::::::::  INSERT WEBLINKS FROM J15 AS WEBLINKS IN J16: jos_weblinks
SET @admin_user_id_new_website=42;

INSERT INTO
	mydb_upgrade.jos_weblinks (
	catid, sid, title, alias, url, description, 
	date, hits, state, ordering, archived, approved, access,
	params,
	language, created, created_by )
SELECT
	catid, sid, title, alias, url, description, 
	date, hits, published, ordering, archived, approved, 1,
	IF(params='', '', CONCAT('{"', REPLACE(REPLACE(params, CHAR(10), '","'), '=', '":"'), '"}')),
	'*', NOW(), @admin_user_id_new_website
FROM
	mydb_livecopy.jos_weblinks;


-- :::::::::  ASSOCIATE J15 CATEGORIES AND NEWSFEEDS: jos_newsfeeds

UPDATE mydb_upgrade.jos_weblinks a, mydb_upgrade.jos_categories b
SET a.catid=b.id
WHERE b.note=CONCAT('Import from J15. PreviousID=catid', a.catid)
AND b.extension='com_weblinks';


-- -----------------------------------------------------------------------------
-- II. 22. updating keys -- now obsolete
-- -----------------------------------------------------------------------------



Further amendments via the GUI

Login to your Joomla! admin panel:
  1. CATEGORIES
    1. Go into Content > Category Manager > Rebuild
    2. Organize the category structure.
  2. USERS
    1. Re-assign "Super Administrators" to "Super Users"
  3. MENUS
    1. Should work but if not click on "Rebuild"

Issues I ran into

joomla Fatal error: Call to a member function getPath categories.php on line 435
I haven't found a way to automate this yet but you can fix all of these in one go by logging into your Joomla! 1.6.0 admin panel > content > category manager > rebuild (icon in top right).

Migrating from Joomla! 1.5 to 1.6

-- *****************************************************************************
--
-- BIG NOTE: REPLACE mydb_livecopy with name of OLD database
-- BIG NOTE: REPLACE mydb_upgrade with name of NEW database
--
-- *****************************************************************************

Add comment

Please note: all comments are reviewed before being published.


Security code
Refresh

Member Login

Joes Latest Members

A huge WELCOME goes to today's newest members:

  • infonat
Member Signups (Activated)
BeforeCurrentTrend
Day21=
Week105ê
Month11224ê
Year2,265612ê

Member Stats
60 guests are currently online.
1,178 members are still deciding.
There are 5,935 members in total.

Latest Comments

Paypal Donations

Want to support my work? Any donation is a blessing :c)