Database/Tables/Collection

From Davical
Jump to: navigation, search
Help
Available languages

Description

This table stores information on "collections". A collection (in DAV terms) is like a directory which will contain files (DAV resources). In our case collections are usually collections of calendar resources.

Fields

Column Type Not Null Defaut Comment
user_no integer NOT NULL references usr(user_no) of the owner
parent_container text references any parent collection which contains this one
dav_name text NOT NULL essentially the pathname within the DAV space (after caldav.php in URL)
dav_etag text an ETag as defined in HTTP/1.1 - a string which will be invariant until the contents have changed (in our case a hash of the contents)
dav_displayname text A user-friendly name to display when a client requests the DAV::displayname property
is_calendar boolean Whether this DAV collection is also a CalDAV calendar collection
created timestamp with time zone
modified timestamp with time zone
public_events_only boolean NOT NULL false Whether this calendar should refuse to store PRIVATE or CONFIDENTIAL events.
publicly_readable boolean NOT NULL false Whether this entire calendar should be readable by anyone.
collection_id bigint NOT NULL nextval A unique ID

Useful SQL

If you want to rename all old collections that were called '.../home/' to '.../calendar/' to match the changed default names for these collections you could do something like the following in psql:

UPDATE collection SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/';
UPDATE property SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/';
UPDATE sync_changes SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/';

Or perhaps from the bash prompt:

psql -U davical_app davical -c "UPDATE collection SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/'"
psql -U davical_app davical -c "UPDATE property SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/'"
psql -U davical_app davical -c "UPDATE sync_changes SET dav_name = replace( dav_name, '/home/', '/calendar/') WHERE dav_name ~ '/[^/]+/home/'"

The need to update the records in the 'property' table has only recently been pointed out to me and will be fixed in an upcoming version.