Sorry for not replying sooner. I was ill for a while after my
holiday and then became busy with work.
Before going any further, I'm afraid there is one step which I
should have included between steps 7 and 8 in my earlier email
(let's call it step 7.5). Don't worry if you have already carried
out step 8, I will deal with this in step 8.5!
7.5 PREVENT CONFLICTS BETWEEN OLD AND NEW RECORD ID NUMBERS
Ensure that the simple_seq counters are set high enough to avoid
conflicts with existing record IDs:
update simple_seq_simple_sys_tree set id = ( select
round(max(id)/100) from simple_sys_tree )
update simple_seq_simple_calendar set id = ( select
round(max(id)/100) from simple_calendar )
update simple_seq_simple_contacts set id = ( select
round(max(id)/100) from simple_contacts )
update simple_seq_simple_emails set id = ( select round(max(id)/100)
from simple_emails )
update simple_seq_simple_files set id = ( select round(max(id)/100)
from simple_files )
...
... and so on for every module that could contain records (even
"deleted" records). If you are not sure which modules might contain
records then the safest option is to do it for every module.
8.5 FIX THE PROBLEM WITH THE OLD TRASH FOLDERS
Assuming you did carry out step 8 before step 7.5 (!), you will need
to take the following corrective action.
Firstly, run these two queries:
update simple_seq_simple_sys_tree set id = id+1
update simple_sys_tree set id = ( select id from
simple_seq_simple_sys_tree ) where id = <OldTrash-ID>
where <OldTrash-ID> is the folder ID number of
System/OldTrash. Then, for each sub-folder of System/OldTrash, run
the following three queries:
update simple_seq_simple_sys_tree set id = id+1
update simple_sys_tree set id = ( select id from
simple_seq_simple_sys_tree ) where parent = <OldTrash-ID> and
ftype = "<folder-type>"
update simple_<folder-type> set folder = ( select id from
simple_seq_simple_sys_tree ) where history like "Item deleted%"
where <folder-type> is the folder type, e.g. "files",
"emails", etc. Continue until you have dealt with every sub-folder
of System/OldTrash.
We are now ready to deal with the folder changes which occurred
after the original installation of Simple Groupware.
I assume you have already carried out step 8 of my earlier post (if
not then please do so now).
The records from the missing folders will still be present in the
simple_files and simple_emails folders, but we need to find how they
were grouped into folders.
Starting with simple_files, we use the following query to obtain a
list of the existing folder numbers
select group_concat(id separator ",") as folderlist from
simple_sys_tree where ftype="files"
The result of this query is a string like
"7001,6101,12301,14501,31001" which we use in the next query
select distinct folder, createdby, count(*) from simple_files where
not folder in ( <folderlist> ) group by folder
where <folderlist> should be replaced by the result of the
first query (without quotes). For example,
select distinct folder, createdby, count(*) from simple_files where
not folder in ( 7001,6101,12301,14501,31001 ) group by folder
The result will be a list showing each missing folder number with
the name of the user who created the folder and the number of items
in the folder, like so
folder createdby count(*)
7001 paul 7
12301 paul 3
Hence, in this example, we have found that there are two missing
folders with ID numbers 7001 and 12301. Armed with this information,
we now manually create two new folders to replace the missing ones,
at the appropriate positions within the folder tree. Using the ID
numbers of the newly created folders, it is a simple matter to move
the records into the new folders by changing their "folder" fields.
If, for example, two new folders with IDs of 19801 and 19901 replace
the original folders 7001 and 12301, respectively, then the
following queries will move the records to the new folders:
update simple_files set folder=19801 where folder=7001
update simple_files set folder=19901 where folder=12301
Having reconstructed the missing simple_files folders, it is a
matter of repeating the above procedure for simple_emails, and so
on.
I will answer your P.S. in a separate thread called "how we use
Simple Groupware".
Regards,
Paul