Move events to a different collection
using a script
archive-old-events.php (in the scripts directory in git, or included in the Debian package as /usr/share/davical/scripts/archive-old-events.php from 1.1.4) can be used by the administrator to move events into an archive collection.
Call with something like e.g.: scripts/archive-old-events.php -a archive -p karora -c calendar -o P-93D Usage: archive-old-events.php [-s server.domain.tld] -p principal [other options] -a <archive_suffix> Appendeded (after a '-') to the name of the original calendar to give the archive calendar name. Default 'archive'. -o <duration> Archive events completed this much prior to the current date. Default 'P-190D' -p <principal> The name of the principal to do the archiving for (required). -c <collection> The name of the collection to do the archiving for (required). -s <server> The servername to be used to identify the DAViCal configuration file. -d xxx Enable debugging where 'xxx' is a comma-separated list of debug subsystems
Moving Events to an Archive Collection
Note: this information may be outdated or incomplete. Use of the above script is recommended!
To archive some old events by deleting them, or by moving them to another collection, you can use some SQL like the following.
You need to update caldav_data table (calendar_item will be maintained with a trigger) with the new path, and the new collection_id.
Here's an example moving non-repeating events, prior to the 1st of January, from /user1/home/ (collection_id 10 for me) to /user1/archive/ (collection_id 1429 for me):
UPDATE caldav_data SET dav_name = replace( caldav_data.dav_name, '/user1/home/', '/user1/archive/'), collection_id = 1429 FROM calendar_item WHERE caldav_data.dav_id = calendar_item.dav_id AND caldav_data.collection_id = 10 AND rrule IS NULL AND dtstart < '2010-01-01';
For that to work you would need to have created the 'archive' calendar
first, of course, and then something like:
SELECT dav_name, collection_id FROM collection WHERE dav_name IN ( '/user1/home/', '/user1/archive/');
to find out the collection IDs.
You could also replace the collection_id finding in above, but it does perhaps make the SQL a little more obscure...
UPDATE caldav_data SET dav_name = replace( caldav_data.dav_name, '/user1/home/', '/user1/archive/'), collection_id = (SELECT collection_id FROM collection WHERE dav_name = '/user1/archive/') FROM calendar_item WHERE caldav_data.dav_id = calendar_item.dav_id AND caldav_data.collection_id = (SELECT collection_id FROM collection WHERE dav_name = '/user1/home/') AND rrule IS NULL AND dtstart < '2010-01-01';
Unfortunately repeating events in this way is *a lot* more complicated,
because you only want to move the ones that have finished, which means
expanding all the instances and working out whether they have
finished... It's probably easier to just manually move them in the
calendar itself.