Unfortunately when you change the tree id, all search engine links like Google, Bing, MSN, Apple, Yahoo are broken. Those searching the internet and finding your site will receive Error 404 not found instead of a TNG page. Since the tree id occurs at or near the end of the URL there is no easy way to correct it using .htaccess. If you have a new site it is better to be patient and let the search engines correct the links. If you don't have a new site or want to capture the 404 errors, I've include a MOD at the bottom of this page that displays a friendly message with a link to search for people, families or sources depending on the error. Rush Krieger wrote the original Person Not Found MOD. I modified it work with families and sources too, so the name was changed to Link Not Found.
As mentioned earlier, it is best to work with a copy so to begin, create a new user and database. If you are not familiar with this procedure, here is a link to Instructions for creating the user and database. Use phpMyAdmin to copy the structure and data into the new empty database. The new database will still have the old tree id but these will be changed using SQL queries.
After you create the new empty database, select the existing TNG database from the left database column. Note the database you are copying from is listed at the top of the window.
Select the Operations tab from the top of the Window.
In the Copy Database to section, enter the new database name, select the Structure and Data radio button, uncheck CREATE DATABASE before copying. Leave Add AUTO INCREMENT, Add Constraints and Adjust Priviledges checked. Then select the Go button In the Copy Database to section.
I'm running a Synology NAS that that still uses php5.6 for phpMyAdmin which gave an error after the copy was complete, although I did not lose any data. If the column count value doesn't match the value count in row 1, click to dismiss the error. If a different error occurs, check the code number to determine the cause with either phpMyAdmin, MySQL or MariaDB.
In any case, if you receive an error, select the new database to make sure the tables were copied. Then compare the number of rows in each table in the new database with the number of rows in each table in the original database. The row counts should match.
To change the tree id use phpMyAdmin to run queries on each of the tables below in the new database.
Note: if a table is empty you do not need to run the query on it.
The SQL query in this example is a conditional query which means only trees named tree-1 will be changed. So if your database has more than one tree, any tree ids not matching tree-1 will not be changed. To run the query replace the default SELECT FROM line in the SQL window with that shown in the code below.
Code: Select all
UPDATE tng_addresses SET gedcom = 'tree1' WHERE gedcom = 'tree-1';
SET gedcom = 'tree1' is the query command that specifies the column to change and the value to place in that column. In this case the value tree1 will be placed in the gedcom column.
WHERE gedcom = 'tree-1' is the conditional command. Only rows containing tree-1 will be changed.
Select Go and run the query which will change the value for the 'gedcom' column in this table. Repeat this procedure for each table listed above that is not empty which will be most of them. Make sure you enter the correct table name for each query that is run.
Once you've changed the tree id you will need to connect TNG to the new database. To connect, edit the TNG config.php file and change $database_name, $database_username and $database_password to match those of the new database just created. If you use a default tree change $defaulttree = to the new tree ID you entered in the SQL query.
At this point, when TNG is restarted, it should connect to the new database with the new tree name. To verify the new tree name is in use, search for an individual and go to their page. In the browser URL window you should see &tree= and the new tree name. Then go to their family group sheet and verify the tree id for the family as well. Media links to anyone in this tree will be retained as well. If you have any problems you can always reconnect TNG to the old database.