[CalendarServer-changes] [10158] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 12 08:37:28 PST 2012
Revision: 10158
http://trac.calendarserver.org//changeset/10158
Author: gaya at apple.com
Date: 2012-12-12 08:37:28 -0800 (Wed, 12 Dec 2012)
Log Message:
-----------
remove INVITE table and bind.SEEN_BY* cols. Move legacy code from twistedcaldav.sharing.py to txdav.caldav.datatstore.file.py.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/dbinspect.py
CalendarServer/trunk/calendarserver/tools/purge.py
CalendarServer/trunk/twistedcaldav/sharing.py
CalendarServer/trunk/txdav/caldav/datastore/file.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
CalendarServer/trunk/txdav/carddav/datastore/file.py
CalendarServer/trunk/txdav/common/datastore/file.py
CalendarServer/trunk/txdav/common/datastore/sql.py
CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql
CalendarServer/trunk/txdav/common/datastore/test/util.py
Added Paths:
-----------
CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v13.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_13_to_14.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_13_to_14.sql
Modified: CalendarServer/trunk/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dbinspect.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/calendarserver/tools/dbinspect.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -21,13 +21,13 @@
of simple commands.
"""
-from caldavclientlibrary.admin.xmlaccounts.recordtypes import recordType_users,\
+from caldavclientlibrary.admin.xmlaccounts.recordtypes import recordType_users, \
recordType_locations, recordType_resources, recordType_groups
from calendarserver.tap.util import directoryFromConfig
from calendarserver.tools import tables
from calendarserver.tools.cmdline import utilityMain
from pycalendar.datetime import PyCalendarDateTime
-from twext.enterprise.dal.syntax import Select, Parameter, Count, Delete,\
+from twext.enterprise.dal.syntax import Select, Parameter, Count, Delete, \
Constant
from twisted.application.service import Service
from twisted.internet.defer import inlineCallbacks, returnValue
@@ -93,13 +93,13 @@
def UserNameFromUID(txn, uid):
record = txn._directory.recordWithGUID(uid)
return record.shortNames[0] if record else "(%s)" % (uid,)
-
+
def UIDFromInput(txn, value):
try:
return str(UUID(value)).upper()
except (ValueError, TypeError):
pass
-
+
record = txn._directory.recordWithShortName(recordType_users, value)
if record is None:
record = txn._directory.recordWithShortName(recordType_locations, value)
@@ -108,11 +108,11 @@
if record is None:
record = txn._directory.recordWithShortName(recordType_groups, value)
return record.guid if record else None
-
+
class Cmd(object):
-
+
_name = None
-
+
@classmethod
def name(cls):
return cls._name
@@ -122,18 +122,18 @@
class TableSizes(Cmd):
-
+
_name = "Show Size of each Table"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
results = []
for dbtable in schema.model.tables: #@UndefinedVariable
dbtable = getattr(schema, dbtable.name)
count = yield self.getTableSize(txn, dbtable)
results.append((dbtable.model.name, count,))
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Table", "Row Count"))
@@ -142,7 +142,7 @@
dbtable,
count,
))
-
+
print "\n"
print "Database Tables (total=%d):\n" % (len(results),)
table.printTable()
@@ -150,21 +150,21 @@
@inlineCallbacks
def getTableSize(self, txn, dbtable):
rows = (yield Select(
- [Count(Constant(1)),],
+ [Count(Constant(1)), ],
From=dbtable,
).on(txn))
returnValue(rows[0][0])
class CalendarHomes(Cmd):
-
+
_name = "List Calendar Homes"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
uids = yield self.getAllHomeUIDs(txn)
-
+
# Print table of results
missing = 0
table = tables.Table()
@@ -177,7 +177,7 @@
uid,
shortname,
))
-
+
print "\n"
print "Calendar Homes (total=%d, missing=%d):\n" % (len(uids), missing,)
table.printTable()
@@ -186,21 +186,21 @@
def getAllHomeUIDs(self, txn):
ch = schema.CALENDAR_HOME
rows = (yield Select(
- [ch.OWNER_UID,],
+ [ch.OWNER_UID, ],
From=ch,
).on(txn))
returnValue(tuple([row[0] for row in rows]))
class CalendarHomesSummary(Cmd):
-
+
_name = "List Calendar Homes with summary information"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
uids = yield self.getCalendars(txn)
-
+
results = {}
for uid, calname, count in sorted(uids, key=lambda x:x[0]):
totalname, totalcount = results.get(uid, (0, 0,))
@@ -208,7 +208,7 @@
totalname += 1
totalcount += count
results[uid] = (totalname, totalcount,)
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendars", "Resources"))
@@ -228,10 +228,10 @@
table.addFooter((
"Average",
"",
- "%.2f" % ((1.0 * totals[1])/totals[0] if totals[0] else 0,),
- "%.2f" % ((1.0 * totals[2])/totals[0] if totals[0] else 0,),
+ "%.2f" % ((1.0 * totals[1]) / totals[0] if totals[0] else 0,),
+ "%.2f" % ((1.0 * totals[2]) / totals[0] if totals[0] else 0,),
))
-
+
print "\n"
print "Calendars with resource count (total=%d):\n" % (len(results),)
table.printTable()
@@ -257,14 +257,14 @@
class Calendars(Cmd):
-
+
_name = "List Calendars"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
uids = yield self.getCalendars(txn)
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendar", "Resources"))
@@ -276,7 +276,7 @@
calname,
count
))
-
+
print "\n"
print "Calendars with resource count (total=%d):\n" % (len(uids),)
table.printTable()
@@ -302,20 +302,20 @@
class CalendarsByOwner(Cmd):
-
+
_name = "List Calendars for Owner UID/Short Name"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
uids = yield self.getCalendars(txn, uid)
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendars", "ID", "Resources"))
- totals = [0, 0,]
+ totals = [0, 0, ]
for uid, calname, resid, count in sorted(uids, key=lambda x:x[1]):
shortname = UserNameFromUID(txn, uid)
table.addRow((
@@ -328,7 +328,7 @@
totals[0] += 1
totals[1] += count
table.addFooter(("Total", "", totals[0], "", totals[1]))
-
+
print "\n"
print "Calendars with resource count (total=%d):\n" % (len(uids),)
table.printTable()
@@ -356,14 +356,14 @@
class Events(Cmd):
-
+
_name = "List Events"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
uids = yield self.getEvents(txn)
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendar", "ID", "Type", "UID"))
@@ -377,7 +377,7 @@
caltype,
caluid
))
-
+
print "\n"
print "Calendar events (total=%d):\n" % (len(uids),)
table.printTable()
@@ -403,12 +403,12 @@
returnValue(tuple(rows))
class EventsByCalendar(Cmd):
-
+
_name = "List Events for a specific calendar"
-
+
@inlineCallbacks
def doIt(self, txn):
-
+
rid = raw_input("Resource-ID: ")
try:
int(rid)
@@ -416,7 +416,7 @@
print 'Resource ID must be an integer'
returnValue(None)
uids = yield self.getEvents(txn, rid)
-
+
# Print table of results
table = tables.Table()
table.addHeader(("Type", "UID", "Resource Name", "Resource ID",))
@@ -427,7 +427,7 @@
rname,
rid,
))
-
+
print "\n"
print "Calendar events (total=%d):\n" % (len(uids),)
table.printTable()
@@ -470,7 +470,7 @@
print "\n"
table.printTable()
print data
-
+
@inlineCallbacks
def getEventData(self, txn, whereClause, whereParams):
ch = schema.CALENDAR_HOME
@@ -495,13 +495,13 @@
returnValue(tuple(rows))
class Event(EventDetails):
-
+
_name = "Get Event Data by Resource-ID"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
rid = raw_input("Resource-ID: ")
try:
int(rid)
@@ -520,13 +520,13 @@
class EventsByUID(EventDetails):
-
+
_name = "Get Event Data by iCalendar UID"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
uid = raw_input("UID: ")
rows = yield self.getData(txn, uid)
if rows:
@@ -541,13 +541,13 @@
class EventsByName(EventDetails):
-
+
_name = "Get Event Data by resource name"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
name = raw_input("Resource Name: ")
rows = yield self.getData(txn, name)
if rows:
@@ -562,13 +562,13 @@
class EventsByOwner(EventDetails):
-
+
_name = "Get Event Data by Owner UID/Short Name"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
rows = yield self.getData(txn, uid)
@@ -584,13 +584,13 @@
class EventsByOwnerCalendar(EventDetails):
-
+
_name = "Get Event Data by Owner UID/Short Name and calendar name"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
name = raw_input("Calendar resource name: ")
@@ -608,13 +608,13 @@
class EventsByPath(EventDetails):
-
+
_name = "Get Event Data by HTTP Path"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
path = raw_input("Path: ")
pathbits = path.split("/")
if len(pathbits) != 6:
@@ -646,13 +646,13 @@
class EventsByContent(EventDetails):
-
+
_name = "Get Event Data by Searching its Text Data"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
uid = raw_input("Search for: ")
rows = yield self.getData(txn, uid)
if rows:
@@ -667,13 +667,13 @@
class EventsInTimerange(Cmd):
-
+
_name = "Get Event Data within a specified time range"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
uid = raw_input("Owner UID/Name: ")
start = raw_input("Start Time (UTC YYYYMMDDTHHMMSSZ or YYYYMMDD): ")
if len(start) == 8:
@@ -698,12 +698,12 @@
if home is None:
print "Could not find calendar home"
returnValue(None)
-
+
yield self.eventsForEachCalendar(home, uid, timerange)
@inlineCallbacks
def eventsForEachCalendar(self, home, uid, timerange):
-
+
calendars = yield home.calendars()
for calendar in calendars:
if calendar.name() == "inbox":
@@ -712,9 +712,9 @@
@inlineCallbacks
def eventsInTimeRange(self, calendar, uid, timerange):
-
+
# Create fake filter element to match time-range
- filter = caldavxml.Filter(
+ filter = caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
timerange,
@@ -747,13 +747,13 @@
class Purge(Cmd):
-
+
_name = "Purge all data from tables"
-
+
@inlineCallbacks
def doIt(self, txn):
-
-
+
+
if raw_input("Do you really want to remove all data [y/n]: ")[0].lower() != 'y':
print "No data removed"
returnValue(None)
@@ -771,13 +771,12 @@
#schema.CALENDAR_OBJECT, - cascades
#schema.TIME_RANGE, - cascades
#schema.TRANSPARENCY, - cascades
-
+
schema.CALENDAR_HOME,
#schema.CALENDAR_HOME_METADATA - cascades
- schema.INVITE,
schema.ATTACHMENT,
-
+
schema.ADDRESSBOOK_OBJECT_REVISIONS,
schema.ADDRESSBOOK,
@@ -795,13 +794,13 @@
for tableschema in wipeout:
yield self.removeTableData(txn, tableschema)
print "Removed rows in table %s" % (tableschema,)
-
+
if calendaruserproxy.ProxyDBService is not None:
calendaruserproxy.ProxyDBService.clean() #@UndefinedVariable
print "Removed all proxies"
else:
print "No proxy database to clean."
-
+
fp = FilePath(config.AttachmentsRoot)
if fp.exists():
for child in fp.children():
@@ -825,7 +824,7 @@
def __init__(self, store, options, reactor, config):
super(DBInspectService, self).__init__()
- self.store = store
+ self.store = store
self.options = options
self.reactor = reactor
self.config = config
@@ -839,7 +838,7 @@
Start the service.
"""
super(DBInspectService, self).startService()
-
+
# Register commands
self.registerCommand(TableSizes)
self.registerCommand(CalendarHomes)
@@ -891,10 +890,10 @@
yield txn.abort()
def printCommands(self):
-
+
print "\n<---- Commands ---->"
for ctr, name in enumerate(self.commands):
- print "%d. %s" % (ctr+1, name,)
+ print "%d. %s" % (ctr + 1, name,)
if self.options["purging"]:
print "P. Purge\n"
print "Q. Quit\n"
@@ -904,7 +903,7 @@
"""
Poll for commands, stopping the reactor when done.
"""
-
+
while True:
self.printCommands()
cmd = raw_input("Command: ")
@@ -918,9 +917,9 @@
except ValueError:
print "Invalid command. Try again.\n"
continue
-
- yield self.runCommandByPosition(position-1)
+ yield self.runCommandByPosition(position - 1)
+
self.reactor.stop()
Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/calendarserver/tools/purge.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -712,7 +712,6 @@
if not dryrun:
(yield storeCalHome.removeUnacceptedShares())
- (yield storeCalHome.removeInvites())
notificationHome = (yield txn.notificationsWithUID(uid))
if notificationHome is not None:
(yield notificationHome.remove())
Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/twistedcaldav/sharing.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -24,7 +24,6 @@
"SharedCollectionMixin",
]
-from twext.python.log import LoggingMixIn
from twext.web2 import responsecode
from twext.web2.http import HTTPError, Response, XMLResponse
from twext.web2.dav.http import ErrorResponse, MultiStatusResponse
@@ -44,12 +43,9 @@
from twistedcaldav.customxml import calendarserver_namespace
from twistedcaldav.directory.wiki import WikiDirectoryService, getWikiAccess
from twistedcaldav.linkresource import LinkFollowerMixIn
-from twistedcaldav.sql import AbstractSQLDatabase, db_prefix
from pycalendar.datetime import PyCalendarDateTime
-import os
-import types
# FIXME: Get rid of these imports
from twistedcaldav.directory.util import TRANSACTION_KEY
@@ -967,164 +963,6 @@
return self._shareeHomeChild.shareMessage()
-class LegacyInvite(object):
-
- def __init__(self, inviteuid, userid, principalUID, common_name, access, state, summary):
- self.inviteuid = inviteuid
- self.principalUID = principalUID
- self.access = access
- self.state = state
- self.summary = summary
-
-
-class InvitesDatabase(AbstractSQLDatabase, LoggingMixIn):
-
- db_basename = db_prefix + "invites"
- schema_version = "1"
- db_type = "invites"
-
- def __init__(self, resource):
- """
- @param resource: the L{CalDAVResource} resource for
- the shared collection. C{resource} must be a calendar/addressbook collection.)
- """
- self.resource = resource
- db_filename = os.path.join(self.resource.fp.path, InvitesDatabase.db_basename)
- super(InvitesDatabase, self).__init__(db_filename, True, autocommit=True)
-
-
- def create(self):
- """
- Create the index and initialize it.
- """
- self._db()
-
-
- def get_dbpath(self):
- return self.resource.fp.child(InvitesDatabase.db_basename).path
-
-
- def set_dbpath(self, newpath):
- pass
-
- dbpath = property(get_dbpath, set_dbpath)
-
- def allRecords(self):
-
- records = self._db_execute("select * from INVITE order by USERID")
- return [self._makeRecord(row) for row in (records if records is not None else ())]
-
-
- def recordForUserID(self, userid):
-
- row = self._db_execute("select * from INVITE where USERID = :1", userid)
- return self._makeRecord(row[0]) if row else None
-
-
- def recordForPrincipalUID(self, principalUID):
-
- row = self._db_execute("select * from INVITE where PRINCIPALUID = :1", principalUID)
- return self._makeRecord(row[0]) if row else None
-
-
- def recordForInviteUID(self, inviteUID):
-
- row = self._db_execute("select * from INVITE where INVITEUID = :1", inviteUID)
- return self._makeRecord(row[0]) if row else None
-
-
- def addOrUpdateRecord(self, record):
-
- self._db_execute("""insert or replace into INVITE (INVITEUID, USERID, PRINCIPALUID, NAME, ACCESS, STATE, SUMMARY)
- values (:1, :2, :3, :4, :5, :6, :7)
- """, record.inviteuid, "userid", record.principalUID, "name", record.access, record.state, record.summary,
- )
-
-
- def removeRecordForInviteUID(self, inviteUID):
-
- self._db_execute("delete from INVITE where INVITEUID = :1", inviteUID)
-
-
- def remove(self):
-
- self._db_close()
- os.remove(self.dbpath)
-
-
- def _db_version(self):
- """
- @return: the schema version assigned to this index.
- """
- return InvitesDatabase.schema_version
-
-
- def _db_type(self):
- """
- @return: the collection type assigned to this index.
- """
- return InvitesDatabase.db_type
-
-
- def _db_init_data_tables(self, q):
- """
- Initialise the underlying database tables.
- @param q: a database cursor to use.
- """
- #
- # INVITE table is the primary table
- # INVITEUID: UID for this invite
- # USERID: identifier of invitee
- # PRINCIPALUID: principal-UID of invitee
- # NAME: common name of invitee
- # ACCESS: Access mode for share
- # STATE: Invite response status
- # SUMMARY: Invite summary
- #
- q.execute(
- """
- create table INVITE (
- INVITEUID text unique,
- USERID text unique,
- PRINCIPALUID text unique,
- NAME text,
- ACCESS text,
- STATE text,
- SUMMARY text
- )
- """
- )
-
- q.execute(
- """
- create index USERID on INVITE (USERID)
- """
- )
- q.execute(
- """
- create index PRINCIPALUID on INVITE (PRINCIPALUID)
- """
- )
- q.execute(
- """
- create index INVITEUID on INVITE (INVITEUID)
- """
- )
-
-
- def _db_upgrade_data_tables(self, q, old_version):
- """
- Upgrade the data from an older version of the DB.
- """
-
- # Nothing to do as we have not changed the schema
- pass
-
-
- def _makeRecord(self, row):
-
- return LegacyInvite(*[str(item) if type(item) == types.UnicodeType else item for item in row])
-
class SharedHomeMixin(LinkFollowerMixIn):
"""
A mix-in for calendar/addressbook homes that defines the operations for
@@ -1484,145 +1322,3 @@
def shareeUID(self):
return self._shareeHomeChild.viewerHome().uid()
-
-class SharedCollectionsDatabase(AbstractSQLDatabase, LoggingMixIn):
-
- db_basename = db_prefix + "shares"
- schema_version = "1"
- db_type = "shares"
-
- def __init__(self, resource):
- """
- @param resource: the L{CalDAVResource} resource for
- the shared collection. C{resource} must be a calendar/addressbook home collection.)
- """
- self.resource = resource
- db_filename = os.path.join(self.resource.fp.path, SharedCollectionsDatabase.db_basename)
- super(SharedCollectionsDatabase, self).__init__(db_filename, True, autocommit=True)
-
-
- def get_dbpath(self):
- return self.resource.fp.child(SharedCollectionsDatabase.db_basename).path
-
-
- def set_dbpath(self, newpath):
- pass
-
- dbpath = property(get_dbpath, set_dbpath)
-
-
- def create(self):
- """
- Create the index and initialize it.
- """
- self._db()
-
-
- def allRecords(self):
-
- records = self._db_execute("select * from SHARES order by LOCALNAME")
- return [self._makeRecord(row) for row in (records if records is not None else ())]
-
-
- def recordForShareUID(self, shareUID):
-
- row = self._db_execute("select * from SHARES where SHAREUID = :1", shareUID)
- return self._makeRecord(row[0]) if row else None
-
-
- def addOrUpdateRecord(self, record):
-
- self._db_execute("""insert or replace into SHARES (SHAREUID, SHARETYPE, HOSTURL, LOCALNAME, SUMMARY)
- values (:1, :2, :3, :4, :5)
- """, record.shareuid, record.sharetype, record.hosturl, record.localname, record.summary,
- )
-
-
- def removeRecordForLocalName(self, localname):
-
- self._db_execute("delete from SHARES where LOCALNAME = :1", localname)
-
-
- def removeRecordForShareUID(self, shareUID):
-
- self._db_execute("delete from SHARES where SHAREUID = :1", shareUID)
-
-
- def remove(self):
-
- self._db_close()
- os.remove(self.dbpath)
-
-
- def directShareID(self, shareeHome, sharerCollection):
- return "Direct-%s-%s" % (shareeHome.resourceID(), sharerCollection.resourceID(),)
-
-
- def _db_version(self):
- """
- @return: the schema version assigned to this index.
- """
- return SharedCollectionsDatabase.schema_version
-
-
- def _db_type(self):
- """
- @return: the collection type assigned to this index.
- """
- return SharedCollectionsDatabase.db_type
-
-
- def _db_init_data_tables(self, q):
- """
- Initialise the underlying database tables.
- @param q: a database cursor to use.
- """
- #
- # SHARES table is the primary table
- # SHAREUID: UID for this share
- # SHARETYPE: type of share: "I" for invite, "D" for direct
- # HOSTURL: URL for data source
- # LOCALNAME: local path name
- # SUMMARY: Share summary
- #
- q.execute(
- """
- create table SHARES (
- SHAREUID text unique,
- SHARETYPE text(1),
- HOSTURL text,
- LOCALNAME text,
- SUMMARY text
- )
- """
- )
-
- q.execute(
- """
- create index SHAREUID on SHARES (SHAREUID)
- """
- )
- q.execute(
- """
- create index HOSTURL on SHARES (HOSTURL)
- """
- )
- q.execute(
- """
- create index LOCALNAME on SHARES (LOCALNAME)
- """
- )
-
-
- def _db_upgrade_data_tables(self, q, old_version):
- """
- Upgrade the data from an older version of the DB.
- """
-
- # Nothing to do as we have not changed the schema
- pass
-
-
- def _makeRecord(self, row):
-
- return SharedCollectionRecord(*[str(item) if type(item) == types.UnicodeType else item for item in row])
Modified: CalendarServer/trunk/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/file.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/caldav/datastore/file.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -44,7 +44,6 @@
from twistedcaldav.caldavxml import ScheduleCalendarTransp, Opaque
from twistedcaldav.config import config
from twistedcaldav.ical import InvalidICalendarDataError
-from twistedcaldav.sharing import InvitesDatabase
from txdav.caldav.icalendarstore import IAttachment
from txdav.caldav.icalendarstore import ICalendar, ICalendarObject
@@ -254,7 +253,6 @@
super(Calendar, self).__init__(name, calendarHome, owned, realName=realName)
self._index = Index(self)
- self._invites = Invites(self)
self._objectResourceClass = CalendarObject
@@ -267,13 +265,6 @@
return ResourceType.calendar #@UndefinedVariable
- def asShared(self):
- """
- Stub for interface-compliance tests.
- """
- # TODO: implement me.
- raise NotImplementedError()
-
ownerCalendarHome = CommonHomeChild.ownerHome
viewerCalendarHome = CommonHomeChild.viewerHome
calendarObjects = CommonHomeChild.objectResources
@@ -908,14 +899,3 @@
yield calendarObject
-
-
-class Invites(object):
- #
- # OK, here's where we get ugly.
- # The index code needs to be rewritten also, but in the meantime...
- #
- def __init__(self, calendar):
- self.calendar = calendar
- stubResource = CalendarStubResource(calendar)
- self._oldInvites = InvitesDatabase(stubResource)
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -68,7 +68,7 @@
_ATTACHMENTS_MODE_NONE, _ATTACHMENTS_MODE_READ, _ATTACHMENTS_MODE_WRITE, \
CALENDAR_HOME_TABLE, CALENDAR_HOME_METADATA_TABLE, \
CALENDAR_AND_CALENDAR_BIND, CALENDAR_OBJECT_REVISIONS_AND_BIND_TABLE, \
- CALENDAR_OBJECT_AND_BIND_TABLE, _BIND_STATUS_INVITED, schema
+ CALENDAR_OBJECT_AND_BIND_TABLE, schema
from txdav.common.icommondatastore import IndexedSearchException, \
InternalDataStoreError, HomeChildNameAlreadyExistsError, \
HomeChildNameNotAllowedError
@@ -339,52 +339,6 @@
yield _requireCalendarWithType("VTODO", "tasks")
- @classproperty
- def _unacceptedSharesQuery(cls): # @NoSelf
- cb = schema.CALENDAR_BIND
- return Select([cb.CALENDAR_RESOURCE_NAME],
- From=cb,
- Where=(cb.CALENDAR_HOME_RESOURCE_ID == Parameter("homeResourceID")).And(cb.BIND_STATUS == _BIND_STATUS_INVITED))
-
-
- @inlineCallbacks
- def removeUnacceptedShares(self):
- """
- Unbinds any collections that have been shared to this home but not yet
- accepted. Associated invite entries are also removed.
- """
- inv = schema.INVITE
- cb = schema.CALENDAR_BIND
- rows = yield self._unacceptedSharesQuery.on(self._txn, homeResourceID=self._resourceID)
- for (resourceName,) in rows:
- kwds = {"ResourceName" : resourceName}
- yield Delete(
- From=inv,
- Where=(
- inv.INVITE_UID == Parameter("ResourceName")
- ),
- ).on(self._txn, **kwds)
-
- yield Delete(
- From=cb,
- Where=(
- cb.CALENDAR_RESOURCE_NAME == Parameter("ResourceName")
- ),
- ).on(self._txn, **kwds)
-
-
- @inlineCallbacks
- def removeInvites(self):
- """
- Remove all remaining invite entries for this home.
- """
- inv = schema.INVITE
- kwds = {"HomeResourceID" : self._resourceID}
- yield Delete(
- From=inv,
- Where=(inv.HOME_RESOURCE_ID == Parameter("HomeResourceID"))
- ).on(self._txn, **kwds)
-
CalendarHome._register(ECALENDARTYPE)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -975,8 +975,6 @@
bind.MESSAGE: "Shared to you",
bind.BIND_MODE: _BIND_MODE_DIRECT,
bind.BIND_STATUS: _BIND_STATUS_ACCEPTED,
- bind.SEEN_BY_OWNER: True,
- bind.SEEN_BY_SHAREE: True,
})
yield _bindCreate.on(self.transactionUnderTest())
sharedCalendar = yield shareeHome.childWithName("shared_1")
Modified: CalendarServer/trunk/txdav/carddav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/file.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/carddav/datastore/file.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -35,7 +35,6 @@
from twisted.python import hashlib
-from twistedcaldav.sharing import InvitesDatabase
from twistedcaldav.vcard import Component as VComponent, InvalidVCardDataError
from txdav.carddav.datastore.index_file import AddressBookIndex as OldIndex
@@ -43,8 +42,8 @@
from txdav.carddav.iaddressbookstore import IAddressBook, IAddressBookObject
from txdav.carddav.iaddressbookstore import IAddressBookHome
-from txdav.common.datastore.file import CommonDataStore, CommonHome,\
- CommonStoreTransaction, CommonHomeChild, CommonObjectResource,\
+from txdav.common.datastore.file import CommonDataStore, CommonHome, \
+ CommonStoreTransaction, CommonHomeChild, CommonObjectResource, \
CommonStubResource
from txdav.common.icommondatastore import NoSuchObjectResourceError, InternalDataStoreError
from txdav.base.datastore.file import hidden, writeOperation
@@ -108,11 +107,10 @@
will eventually have on disk.
@type realName: C{str}
"""
-
+
super(AddressBook, self).__init__(name, addressbookHome, owned, realName=realName)
self._index = Index(self)
- self._invites = Invites(self)
self._objectResourceClass = AddressBookObject
@property
@@ -238,7 +236,7 @@
if unfixed:
self.log_error("Address data at %s had unfixable problems:\n %s" % (self._path.path, "\n ".join(unfixed),))
-
+
if fixed:
self.log_error("Address data at %s had fixable problems:\n %s" % (self._path.path, "\n ".join(fixed),))
@@ -270,7 +268,7 @@
"File corruption detected (improper start) in file: %s"
% (self._path.path,)
)
-
+
self._objectText = text
return text
@@ -332,12 +330,3 @@
yield addressbookObject
-class Invites(object):
- #
- # OK, here's where we get ugly.
- # The index code needs to be rewritten also, but in the meantime...
- #
- def __init__(self, addressbook):
- self.addressbook = addressbook
- stubResource = AddressBookStubResource(addressbook)
- self._oldInvites = InvitesDatabase(stubResource)
Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/common/datastore/file.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -36,7 +36,6 @@
from twistedcaldav.customxml import NotificationType
from twistedcaldav.notifications import NotificationRecord
from twistedcaldav.notifications import NotificationsDatabase as OldNotificationIndex
-from twistedcaldav.sharing import SharedCollectionsDatabase
from txdav.caldav.icalendarstore import ICalendarStore, BIND_OWN
from txdav.common.datastore.common import HomeChildBase
@@ -58,6 +57,9 @@
from zope.interface import implements, directlyProvides
import uuid
+from twistedcaldav.sql import AbstractSQLDatabase, db_prefix
+import os
+import types
ECALENDARTYPE = 0
EADDRESSBOOKTYPE = 1
@@ -376,6 +378,158 @@
+class SharedCollectionRecord(object):
+
+ def __init__(self, shareuid, sharetype, hosturl, localname, summary):
+ self.shareuid = shareuid
+ self.sharetype = sharetype
+ self.hosturl = hosturl
+ self.localname = localname
+ self.summary = summary
+
+
+class SharedCollectionsDatabase(AbstractSQLDatabase, LoggingMixIn):
+
+ db_basename = db_prefix + "shares"
+ schema_version = "1"
+ db_type = "shares"
+
+ def __init__(self, resource):
+ """
+ @param resource: the L{CalDAVResource} resource for
+ the shared collection. C{resource} must be a calendar/addressbook home collection.)
+ """
+ self.resource = resource
+ db_filename = os.path.join(self.resource.fp.path, SharedCollectionsDatabase.db_basename)
+ super(SharedCollectionsDatabase, self).__init__(db_filename, True, autocommit=True)
+
+
+ def get_dbpath(self):
+ return self.resource.fp.child(SharedCollectionsDatabase.db_basename).path
+
+
+ def set_dbpath(self, newpath):
+ pass
+
+ dbpath = property(get_dbpath, set_dbpath)
+
+
+ def create(self):
+ """
+ Create the index and initialize it.
+ """
+ self._db()
+
+
+ def allRecords(self):
+
+ records = self._db_execute("select * from SHARES order by LOCALNAME")
+ return [self._makeRecord(row) for row in (records if records is not None else ())]
+
+
+ def recordForShareUID(self, shareUID):
+
+ row = self._db_execute("select * from SHARES where SHAREUID = :1", shareUID)
+ return self._makeRecord(row[0]) if row else None
+
+
+ def addOrUpdateRecord(self, record):
+
+ self._db_execute("""insert or replace into SHARES (SHAREUID, SHARETYPE, HOSTURL, LOCALNAME, SUMMARY)
+ values (:1, :2, :3, :4, :5)
+ """, record.shareuid, record.sharetype, record.hosturl, record.localname, record.summary,
+ )
+
+
+ def removeRecordForLocalName(self, localname):
+
+ self._db_execute("delete from SHARES where LOCALNAME = :1", localname)
+
+
+ def removeRecordForShareUID(self, shareUID):
+
+ self._db_execute("delete from SHARES where SHAREUID = :1", shareUID)
+
+
+ def remove(self):
+
+ self._db_close()
+ os.remove(self.dbpath)
+
+
+ def directShareID(self, shareeHome, sharerCollection):
+ return "Direct-%s-%s" % (shareeHome.resourceID(), sharerCollection.resourceID(),)
+
+
+ def _db_version(self):
+ """
+ @return: the schema version assigned to this index.
+ """
+ return SharedCollectionsDatabase.schema_version
+
+
+ def _db_type(self):
+ """
+ @return: the collection type assigned to this index.
+ """
+ return SharedCollectionsDatabase.db_type
+
+
+ def _db_init_data_tables(self, q):
+ """
+ Initialise the underlying database tables.
+ @param q: a database cursor to use.
+ """
+ #
+ # SHARES table is the primary table
+ # SHAREUID: UID for this share
+ # SHARETYPE: type of share: "I" for invite, "D" for direct
+ # HOSTURL: URL for data source
+ # LOCALNAME: local path name
+ # SUMMARY: Share summary
+ #
+ q.execute(
+ """
+ create table SHARES (
+ SHAREUID text unique,
+ SHARETYPE text(1),
+ HOSTURL text,
+ LOCALNAME text,
+ SUMMARY text
+ )
+ """
+ )
+
+ q.execute(
+ """
+ create index SHAREUID on SHARES (SHAREUID)
+ """
+ )
+ q.execute(
+ """
+ create index HOSTURL on SHARES (HOSTURL)
+ """
+ )
+ q.execute(
+ """
+ create index LOCALNAME on SHARES (LOCALNAME)
+ """
+ )
+
+
+ def _db_upgrade_data_tables(self, q, old_version):
+ """
+ Upgrade the data from an older version of the DB.
+ """
+
+ # Nothing to do as we have not changed the schema
+ pass
+
+
+ def _makeRecord(self, row):
+
+ return SharedCollectionRecord(*[str(item) if type(item) == types.UnicodeType else item for item in row])
+
class CommonHome(FileMetaDataMixin, LoggingMixIn):
# All these need to be initialized by derived classes for each store type
@@ -1113,7 +1267,21 @@
self._transaction.postCommit(notifier.notify)
self._transaction.notificationAddedForObject(self)
+ @inlineCallbacks
+ def asInvited(self):
+ """
+ Stub for interface-compliance tests.
+ """
+ yield None
+ returnValue([])
+ @inlineCallbacks
+ def asShared(self):
+ """
+ Stub for interface-compliance tests.
+ """
+ yield None
+ returnValue([])
class CommonObjectResource(FileMetaDataMixin, LoggingMixIn, FancyEqMixin):
"""
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -1385,10 +1385,8 @@
if child is None:
raise NoSuchHomeChildError()
- try:
- yield child.remove()
- finally:
- self._children.pop(name, None)
+ yield child.remove()
+ self._children.pop(name, None)
@classproperty
@@ -1807,7 +1805,20 @@
self._txn.notificationAddedForObject(self)
+ @inlineCallbacks
+ def removeUnacceptedShares(self):
+ """
+ Unbinds any collections that have been shared to this home but not yet
+ accepted. Associated invite entries are also removed.
+ """
+ bind = self._bindSchema
+ kwds = {"homeResourceID" : self._resourceID}
+ yield Delete(
+ From=bind,
+ Where=(bind.HOME_RESOURCE_ID == Parameter("homeResourceID")).And(bind.BIND_STATUS != _BIND_STATUS_ACCEPTED)
+ ).on(self._txn, **kwds)
+
class _SharedSyncLogic(object):
"""
Logic for maintaining sync-token shared between notification collections and
@@ -2882,8 +2893,6 @@
bind.BIND_MODE: Parameter("mode"),
bind.BIND_STATUS: Parameter("bindStatus"),
bind.MESSAGE: Parameter("message"),
- bind.SEEN_BY_OWNER: Parameter("seenByOwner"),
- bind.SEEN_BY_SHAREE: Parameter("seenBySharee"),
})
@@ -2912,8 +2921,7 @@
# Bind table needs entry
yield cls._bindInsertQuery.on(
home._txn, homeID=home._resourceID, resourceID=resourceID,
- name=name, mode=_BIND_MODE_OWN, seenByOwner=True,
- seenBySharee=True, bindStatus=_BIND_STATUS_ACCEPTED,
+ name=name, mode=_BIND_MODE_OWN, bindStatus=_BIND_STATUS_ACCEPTED,
message=None,
)
@@ -3339,13 +3347,11 @@
def _removeObjectResource(self, child):
name = child.name()
uid = child.uid()
- try:
- yield child.remove()
- finally:
- self._objects.pop(name, None)
- self._objects.pop(uid, None)
- yield self._deleteRevision(name)
- yield self.notifyChanged()
+ yield child.remove()
+ self._objects.pop(name, None)
+ self._objects.pop(uid, None)
+ yield self._deleteRevision(name)
+ yield self.notifyChanged()
@classproperty
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -34,14 +34,6 @@
"MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
);
-create table INVITE (
- "INVITE_UID" nvarchar2(255),
- "NAME" nvarchar2(255),
- "RECIPIENT_ADDRESS" nvarchar2(255),
- "HOME_RESOURCE_ID" integer not null,
- "RESOURCE_ID" integer not null
-);
-
create table NOTIFICATION_HOME (
"RESOURCE_ID" integer primary key,
"OWNER_UID" nvarchar2(255) unique
@@ -65,8 +57,6 @@
"CALENDAR_RESOURCE_NAME" nvarchar2(255),
"BIND_MODE" integer not null,
"BIND_STATUS" integer not null,
- "SEEN_BY_OWNER" integer not null,
- "SEEN_BY_SHAREE" integer not null,
"MESSAGE" nclob,
primary key("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_ID"),
unique("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_NAME")
@@ -216,8 +206,6 @@
"ADDRESSBOOK_RESOURCE_NAME" nvarchar2(255),
"BIND_MODE" integer not null,
"BIND_STATUS" integer not null,
- "SEEN_BY_OWNER" integer not null,
- "SEEN_BY_SHAREE" integer not null,
"MESSAGE" nclob,
primary key("ADDRESSBOOK_HOME_RESOURCE_ID", "ADDRESSBOOK_RESOURCE_ID"),
unique("ADDRESSBOOK_HOME_RESOURCE_ID", "ADDRESSBOOK_RESOURCE_NAME")
@@ -277,21 +265,10 @@
"VALUE" nvarchar2(255)
);
-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '13');
+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '14');
insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '3');
insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '1');
-create index INVITE_INVITE_UID_9b0902ff on INVITE (
- INVITE_UID
-);
-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
- RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
- HOME_RESOURCE_ID
-);
-
create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
NOTIFICATION_HOME_RESOURCE_ID
);
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -81,24 +81,6 @@
);
-------------------------
--- Sharing Invitation --
-------------------------
-
-create table INVITE (
- INVITE_UID varchar(255) not null,
- NAME varchar(255) not null,
- RECIPIENT_ADDRESS varchar(255) not null,
- HOME_RESOURCE_ID integer not null,
- RESOURCE_ID integer not null
-
- -- Need primary key on (INVITE_UID, NAME, RECIPIENT_ADDRESS)?
-);
-
-create index INVITE_INVITE_UID on INVITE(INVITE_UID);
-create index INVITE_RESOURCE_ID on INVITE(RESOURCE_ID);
-create index INVITE_HOME_RESOURCE_ID on INVITE(HOME_RESOURCE_ID);
-
---------------------------
-- Sharing Notifications --
---------------------------
@@ -140,8 +122,6 @@
CALENDAR_RESOURCE_NAME varchar(255),
BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
- SEEN_BY_OWNER boolean not null,
- SEEN_BY_SHAREE boolean not null,
MESSAGE text,
primary key(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID), -- implicit index
@@ -406,8 +386,6 @@
ADDRESSBOOK_RESOURCE_NAME varchar(255),
BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
- SEEN_BY_OWNER boolean not null,
- SEEN_BY_SHAREE boolean not null,
MESSAGE text, -- FIXME: xml?
primary key (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_ID), -- implicit index
@@ -526,6 +504,6 @@
VALUE varchar(255)
);
-insert into CALENDARSERVER values ('VERSION', '13');
+insert into CALENDARSERVER values ('VERSION', '14');
insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '3');
insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '1');
Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -0,0 +1,379 @@
+create sequence RESOURCE_ID_SEQ;
+create sequence INSTANCE_ID_SEQ;
+create sequence ATTACHMENT_ID_SEQ;
+create sequence REVISION_SEQ;
+create table NODE_INFO (
+ "HOSTNAME" nvarchar2(255),
+ "PID" integer not null,
+ "PORT" integer not null,
+ "TIME" timestamp default CURRENT_TIMESTAMP at time zone 'UTC' not null,
+ primary key("HOSTNAME", "PORT")
+);
+
+create table CALENDAR_HOME (
+ "RESOURCE_ID" integer primary key,
+ "OWNER_UID" nvarchar2(255) unique,
+ "DATAVERSION" integer default 0 not null
+);
+
+create table CALENDAR_HOME_METADATA (
+ "RESOURCE_ID" integer primary key references CALENDAR_HOME on delete cascade,
+ "QUOTA_USED_BYTES" integer default 0 not null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table CALENDAR (
+ "RESOURCE_ID" integer primary key
+);
+
+create table CALENDAR_METADATA (
+ "RESOURCE_ID" integer primary key references CALENDAR on delete cascade,
+ "SUPPORTED_COMPONENTS" nvarchar2(255) default null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table INVITE (
+ "INVITE_UID" nvarchar2(255),
+ "NAME" nvarchar2(255),
+ "RECIPIENT_ADDRESS" nvarchar2(255),
+ "HOME_RESOURCE_ID" integer not null,
+ "RESOURCE_ID" integer not null
+);
+
+create table NOTIFICATION_HOME (
+ "RESOURCE_ID" integer primary key,
+ "OWNER_UID" nvarchar2(255) unique
+);
+
+create table NOTIFICATION (
+ "RESOURCE_ID" integer primary key,
+ "NOTIFICATION_HOME_RESOURCE_ID" integer not null references NOTIFICATION_HOME,
+ "NOTIFICATION_UID" nvarchar2(255),
+ "XML_TYPE" nvarchar2(255),
+ "XML_DATA" nclob,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique("NOTIFICATION_UID", "NOTIFICATION_HOME_RESOURCE_ID")
+);
+
+create table CALENDAR_BIND (
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "CALENDAR_RESOURCE_NAME" nvarchar2(255),
+ "BIND_MODE" integer not null,
+ "BIND_STATUS" integer not null,
+ "SEEN_BY_OWNER" integer not null,
+ "SEEN_BY_SHAREE" integer not null,
+ "MESSAGE" nclob,
+ primary key("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_ID"),
+ unique("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_NAME")
+);
+
+create table CALENDAR_BIND_MODE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('own', 0);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('write', 2);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('direct', 3);
+create table CALENDAR_BIND_STATUS (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invited', 0);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('accepted', 1);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('declined', 2);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invalid', 3);
+create table CALENDAR_OBJECT (
+ "RESOURCE_ID" integer primary key,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "ICALENDAR_TEXT" nclob,
+ "ICALENDAR_UID" nvarchar2(255),
+ "ICALENDAR_TYPE" nvarchar2(255),
+ "ATTACHMENTS_MODE" integer default 0 not null,
+ "DROPBOX_ID" nvarchar2(255),
+ "ORGANIZER" nvarchar2(255),
+ "ORGANIZER_OBJECT" integer references CALENDAR_OBJECT,
+ "RECURRANCE_MIN" date,
+ "RECURRANCE_MAX" date,
+ "ACCESS" integer default 0 not null,
+ "SCHEDULE_OBJECT" integer default 0,
+ "SCHEDULE_TAG" nvarchar2(36) default null,
+ "SCHEDULE_ETAGS" nclob default null,
+ "PRIVATE_COMMENTS" integer default 0 not null,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique("CALENDAR_RESOURCE_ID", "RESOURCE_NAME")
+);
+
+create table CALENDAR_OBJECT_ATTACHMENTS_MO (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (DESCRIPTION, ID) values ('none', 0);
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (DESCRIPTION, ID) values ('write', 2);
+create table CALENDAR_ACCESS_TYPE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(32) unique
+);
+
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('', 0);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('public', 1);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('private', 2);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('confidential', 3);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('restricted', 4);
+create table TIME_RANGE (
+ "INSTANCE_ID" integer primary key,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "CALENDAR_OBJECT_RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "FLOATING" integer not null,
+ "START_DATE" timestamp not null,
+ "END_DATE" timestamp not null,
+ "FBTYPE" integer not null,
+ "TRANSPARENT" integer not null
+);
+
+create table FREE_BUSY_TYPE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('unknown', 0);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('free', 1);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy', 2);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-unavailable', 3);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-tentative', 4);
+create table TRANSPARENCY (
+ "TIME_RANGE_INSTANCE_ID" integer not null references TIME_RANGE on delete cascade,
+ "USER_ID" nvarchar2(255),
+ "TRANSPARENT" integer not null
+);
+
+create table ATTACHMENT (
+ "ATTACHMENT_ID" integer primary key,
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "DROPBOX_ID" nvarchar2(255),
+ "CONTENT_TYPE" nvarchar2(255),
+ "SIZE" integer not null,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "PATH" nvarchar2(1024)
+);
+
+create table ATTACHMENT_CALENDAR_OBJECT (
+ "ATTACHMENT_ID" integer not null references ATTACHMENT on delete cascade,
+ "MANAGED_ID" nvarchar2(255),
+ "CALENDAR_OBJECT_RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ primary key("ATTACHMENT_ID", "CALENDAR_OBJECT_RESOURCE_ID"),
+ unique("MANAGED_ID", "CALENDAR_OBJECT_RESOURCE_ID")
+);
+
+create table RESOURCE_PROPERTY (
+ "RESOURCE_ID" integer not null,
+ "NAME" nvarchar2(255),
+ "VALUE" nclob,
+ "VIEWER_UID" nvarchar2(255),
+ primary key("RESOURCE_ID", "NAME", "VIEWER_UID")
+);
+
+create table ADDRESSBOOK_HOME (
+ "RESOURCE_ID" integer primary key,
+ "OWNER_UID" nvarchar2(255) unique,
+ "DATAVERSION" integer default 0 not null
+);
+
+create table ADDRESSBOOK_HOME_METADATA (
+ "RESOURCE_ID" integer primary key references ADDRESSBOOK_HOME on delete cascade,
+ "QUOTA_USED_BYTES" integer default 0 not null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table ADDRESSBOOK (
+ "RESOURCE_ID" integer primary key
+);
+
+create table ADDRESSBOOK_METADATA (
+ "RESOURCE_ID" integer primary key references ADDRESSBOOK on delete cascade,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table ADDRESSBOOK_BIND (
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME,
+ "ADDRESSBOOK_RESOURCE_ID" integer not null references ADDRESSBOOK on delete cascade,
+ "ADDRESSBOOK_RESOURCE_NAME" nvarchar2(255),
+ "BIND_MODE" integer not null,
+ "BIND_STATUS" integer not null,
+ "SEEN_BY_OWNER" integer not null,
+ "SEEN_BY_SHAREE" integer not null,
+ "MESSAGE" nclob,
+ primary key("ADDRESSBOOK_HOME_RESOURCE_ID", "ADDRESSBOOK_RESOURCE_ID"),
+ unique("ADDRESSBOOK_HOME_RESOURCE_ID", "ADDRESSBOOK_RESOURCE_NAME")
+);
+
+create table ADDRESSBOOK_OBJECT (
+ "RESOURCE_ID" integer primary key,
+ "ADDRESSBOOK_RESOURCE_ID" integer not null references ADDRESSBOOK on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "VCARD_TEXT" nclob,
+ "VCARD_UID" nvarchar2(255),
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique("ADDRESSBOOK_RESOURCE_ID", "RESOURCE_NAME"),
+ unique("ADDRESSBOOK_RESOURCE_ID", "VCARD_UID")
+);
+
+create table CALENDAR_OBJECT_REVISIONS (
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "CALENDAR_RESOURCE_ID" integer references CALENDAR,
+ "CALENDAR_NAME" nvarchar2(255) default null,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null
+);
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME,
+ "ADDRESSBOOK_RESOURCE_ID" integer references ADDRESSBOOK,
+ "ADDRESSBOOK_NAME" nvarchar2(255) default null,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null
+);
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+ "NOTIFICATION_HOME_RESOURCE_ID" integer not null references NOTIFICATION_HOME on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null,
+ unique("NOTIFICATION_HOME_RESOURCE_ID", "RESOURCE_NAME")
+);
+
+create table APN_SUBSCRIPTIONS (
+ "TOKEN" nvarchar2(255),
+ "RESOURCE_KEY" nvarchar2(255),
+ "MODIFIED" integer not null,
+ "SUBSCRIBER_GUID" nvarchar2(255),
+ "USER_AGENT" nvarchar2(255) default null,
+ "IP_ADDR" nvarchar2(255) default null,
+ primary key("TOKEN", "RESOURCE_KEY")
+);
+
+create table CALENDARSERVER (
+ "NAME" nvarchar2(255) primary key,
+ "VALUE" nvarchar2(255)
+);
+
+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '13');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '3');
+insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '1');
+create index INVITE_INVITE_UID_9b0902ff on INVITE (
+ INVITE_UID
+);
+
+create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
+ RESOURCE_ID
+);
+
+create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
+ HOME_RESOURCE_ID
+);
+
+create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
+ NOTIFICATION_HOME_RESOURCE_ID
+);
+
+create index CALENDAR_BIND_RESOURC_e57964d4 on CALENDAR_BIND (
+ CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_CALEN_a9a453a9 on CALENDAR_OBJECT (
+ CALENDAR_RESOURCE_ID,
+ ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_CALEN_96e83b73 on CALENDAR_OBJECT (
+ CALENDAR_RESOURCE_ID,
+ RECURRANCE_MAX
+);
+
+create index CALENDAR_OBJECT_ORGAN_7ce24750 on CALENDAR_OBJECT (
+ ORGANIZER_OBJECT
+);
+
+create index CALENDAR_OBJECT_DROPB_de041d80 on CALENDAR_OBJECT (
+ DROPBOX_ID
+);
+
+create index TIME_RANGE_CALENDAR_R_beb6e7eb on TIME_RANGE (
+ CALENDAR_RESOURCE_ID
+);
+
+create index TIME_RANGE_CALENDAR_O_acf37bd1 on TIME_RANGE (
+ CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index TRANSPARENCY_TIME_RAN_5f34467f on TRANSPARENCY (
+ TIME_RANGE_INSTANCE_ID
+);
+
+create index ATTACHMENT_CALENDAR_H_0078845c on ATTACHMENT (
+ CALENDAR_HOME_RESOURCE_ID
+);
+
+create index ADDRESSBOOK_BIND_RESO_205aa75c on ADDRESSBOOK_BIND (
+ ADDRESSBOOK_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_3a3956c4 on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_HOME_RESOURCE_ID,
+ CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_2643d556 on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_RESOURCE_ID,
+ RESOURCE_NAME
+);
+
+create index CALENDAR_OBJECT_REVIS_265c8acf on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_RESOURCE_ID,
+ REVISION
+);
+
+create index ADDRESSBOOK_OBJECT_RE_f460d62d on ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_HOME_RESOURCE_ID,
+ ADDRESSBOOK_RESOURCE_ID
+);
+
+create index ADDRESSBOOK_OBJECT_RE_9a848f39 on ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_RESOURCE_ID,
+ RESOURCE_NAME
+);
+
+create index ADDRESSBOOK_OBJECT_RE_cb101e6b on ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_RESOURCE_ID,
+ REVISION
+);
+
+create index NOTIFICATION_OBJECT_R_036a9cee on NOTIFICATION_OBJECT_REVISIONS (
+ NOTIFICATION_HOME_RESOURCE_ID,
+ REVISION
+);
+
+create index APN_SUBSCRIPTIONS_RES_9610d78e on APN_SUBSCRIPTIONS (
+ RESOURCE_KEY
+);
+
Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v13.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v13.sql (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v13.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -0,0 +1,531 @@
+-- -*- test-case-name: txdav.caldav.datastore.test.test_sql,txdav.carddav.datastore.test.test_sql -*-
+
+----
+-- Copyright (c) 2010-2012 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+-----------------
+-- Resource ID --
+-----------------
+
+create sequence RESOURCE_ID_SEQ;
+
+-------------------------
+-- Cluster Bookkeeping --
+-------------------------
+
+-- Information about a process connected to this database.
+
+-- Note that this must match the node info schema in twext.enterprise.queue.
+create table NODE_INFO (
+ HOSTNAME varchar(255) not null,
+ PID integer not null,
+ PORT integer not null,
+ TIME timestamp not null default timezone('UTC', CURRENT_TIMESTAMP),
+
+ primary key (HOSTNAME, PORT)
+);
+
+
+-------------------
+-- Calendar Home --
+-------------------
+
+create table CALENDAR_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ OWNER_UID varchar(255) not null unique, -- implicit index
+ DATAVERSION integer default 0 not null
+);
+
+----------------------------
+-- Calendar Home Metadata --
+----------------------------
+
+create table CALENDAR_HOME_METADATA (
+ RESOURCE_ID integer primary key references CALENDAR_HOME on delete cascade, -- implicit index
+ QUOTA_USED_BYTES integer default 0 not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+--------------
+-- Calendar --
+--------------
+
+create table CALENDAR (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
+);
+
+
+-----------------------
+-- Calendar Metadata --
+-----------------------
+
+create table CALENDAR_METADATA (
+ RESOURCE_ID integer primary key references CALENDAR on delete cascade, -- implicit index
+ SUPPORTED_COMPONENTS varchar(255) default null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+------------------------
+-- Sharing Invitation --
+------------------------
+
+create table INVITE (
+ INVITE_UID varchar(255) not null,
+ NAME varchar(255) not null,
+ RECIPIENT_ADDRESS varchar(255) not null,
+ HOME_RESOURCE_ID integer not null,
+ RESOURCE_ID integer not null
+
+ -- Need primary key on (INVITE_UID, NAME, RECIPIENT_ADDRESS)?
+);
+
+create index INVITE_INVITE_UID on INVITE(INVITE_UID);
+create index INVITE_RESOURCE_ID on INVITE(RESOURCE_ID);
+create index INVITE_HOME_RESOURCE_ID on INVITE(HOME_RESOURCE_ID);
+
+---------------------------
+-- Sharing Notifications --
+---------------------------
+
+create table NOTIFICATION_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ OWNER_UID varchar(255) not null unique -- implicit index
+);
+
+create table NOTIFICATION (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ NOTIFICATION_HOME_RESOURCE_ID integer not null references NOTIFICATION_HOME,
+ NOTIFICATION_UID varchar(255) not null,
+ XML_TYPE varchar(255) not null,
+ XML_DATA text not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique(NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID) -- implicit index
+);
+
+create index NOTIFICATION_NOTIFICATION_HOME_RESOURCE_ID on
+ NOTIFICATION(NOTIFICATION_HOME_RESOURCE_ID);
+
+-------------------
+-- Calendar Bind --
+-------------------
+
+-- Joins CALENDAR_HOME and CALENDAR
+
+create table CALENDAR_BIND (
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+
+ -- An invitation which hasn't been accepted yet will not yet have a resource
+ -- name, so this field may be null.
+
+ CALENDAR_RESOURCE_NAME varchar(255),
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ SEEN_BY_OWNER boolean not null,
+ SEEN_BY_SHAREE boolean not null,
+ MESSAGE text,
+
+ primary key(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID), -- implicit index
+ unique(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_NAME) -- implicit index
+);
+
+create index CALENDAR_BIND_RESOURCE_ID on CALENDAR_BIND(CALENDAR_RESOURCE_ID);
+
+-- Enumeration of calendar bind modes
+
+create table CALENDAR_BIND_MODE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_MODE values (0, 'own' );
+insert into CALENDAR_BIND_MODE values (1, 'read' );
+insert into CALENDAR_BIND_MODE values (2, 'write');
+insert into CALENDAR_BIND_MODE values (3, 'direct');
+
+-- Enumeration of statuses
+
+create table CALENDAR_BIND_STATUS (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_STATUS values (0, 'invited' );
+insert into CALENDAR_BIND_STATUS values (1, 'accepted');
+insert into CALENDAR_BIND_STATUS values (2, 'declined');
+insert into CALENDAR_BIND_STATUS values (3, 'invalid');
+
+
+---------------------
+-- Calendar Object --
+---------------------
+
+create table CALENDAR_OBJECT (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+ RESOURCE_NAME varchar(255) not null,
+ ICALENDAR_TEXT text not null,
+ ICALENDAR_UID varchar(255) not null,
+ ICALENDAR_TYPE varchar(255) not null,
+ ATTACHMENTS_MODE integer default 0 not null, -- enum CALENDAR_OBJECT_ATTACHMENTS_MODE
+ DROPBOX_ID varchar(255),
+ ORGANIZER varchar(255),
+ ORGANIZER_OBJECT integer references CALENDAR_OBJECT,
+ RECURRANCE_MIN date, -- minimum date that recurrences have been expanded to.
+ RECURRANCE_MAX date, -- maximum date that recurrences have been expanded to.
+ ACCESS integer default 0 not null,
+ SCHEDULE_OBJECT boolean default false,
+ SCHEDULE_TAG varchar(36) default null,
+ SCHEDULE_ETAGS text default null,
+ PRIVATE_COMMENTS boolean default false not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (CALENDAR_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+
+ -- since the 'inbox' is a 'calendar resource' for the purpose of storing
+ -- calendar objects, this constraint has to be selectively enforced by the
+ -- application layer.
+
+ -- unique(CALENDAR_RESOURCE_ID, ICALENDAR_UID)
+);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_AND_ICALENDAR_UID on
+ CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, ICALENDAR_UID);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_RECURRANCE_MAX on
+ CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, RECURRANCE_MAX);
+
+create index CALENDAR_OBJECT_ORGANIZER_OBJECT on
+ CALENDAR_OBJECT(ORGANIZER_OBJECT);
+
+create index CALENDAR_OBJECT_DROPBOX_ID on
+ CALENDAR_OBJECT(DROPBOX_ID);
+
+-- Enumeration of attachment modes
+
+create table CALENDAR_OBJECT_ATTACHMENTS_MODE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_OBJECT_ATTACHMENTS_MODE values (0, 'none' );
+insert into CALENDAR_OBJECT_ATTACHMENTS_MODE values (1, 'read' );
+insert into CALENDAR_OBJECT_ATTACHMENTS_MODE values (2, 'write');
+
+
+-- Enumeration of calendar access types
+
+create table CALENDAR_ACCESS_TYPE (
+ ID integer primary key,
+ DESCRIPTION varchar(32) not null unique
+);
+
+insert into CALENDAR_ACCESS_TYPE values (0, '' );
+insert into CALENDAR_ACCESS_TYPE values (1, 'public' );
+insert into CALENDAR_ACCESS_TYPE values (2, 'private' );
+insert into CALENDAR_ACCESS_TYPE values (3, 'confidential' );
+insert into CALENDAR_ACCESS_TYPE values (4, 'restricted' );
+
+-----------------
+-- Instance ID --
+-----------------
+
+create sequence INSTANCE_ID_SEQ;
+
+
+----------------
+-- Time Range --
+----------------
+
+create table TIME_RANGE (
+ INSTANCE_ID integer primary key default nextval('INSTANCE_ID_SEQ'), -- implicit index
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+ CALENDAR_OBJECT_RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ FLOATING boolean not null,
+ START_DATE timestamp not null,
+ END_DATE timestamp not null,
+ FBTYPE integer not null,
+ TRANSPARENT boolean not null
+);
+
+create index TIME_RANGE_CALENDAR_RESOURCE_ID on
+ TIME_RANGE(CALENDAR_RESOURCE_ID);
+create index TIME_RANGE_CALENDAR_OBJECT_RESOURCE_ID on
+ TIME_RANGE(CALENDAR_OBJECT_RESOURCE_ID);
+
+
+-- Enumeration of free/busy types
+
+create table FREE_BUSY_TYPE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into FREE_BUSY_TYPE values (0, 'unknown' );
+insert into FREE_BUSY_TYPE values (1, 'free' );
+insert into FREE_BUSY_TYPE values (2, 'busy' );
+insert into FREE_BUSY_TYPE values (3, 'busy-unavailable');
+insert into FREE_BUSY_TYPE values (4, 'busy-tentative' );
+
+
+------------------
+-- Transparency --
+------------------
+
+create table TRANSPARENCY (
+ TIME_RANGE_INSTANCE_ID integer not null references TIME_RANGE on delete cascade,
+ USER_ID varchar(255) not null,
+ TRANSPARENT boolean not null
+);
+
+create index TRANSPARENCY_TIME_RANGE_INSTANCE_ID on
+ TRANSPARENCY(TIME_RANGE_INSTANCE_ID);
+
+
+----------------
+-- Attachment --
+----------------
+
+create sequence ATTACHMENT_ID_SEQ;
+
+create table ATTACHMENT (
+ ATTACHMENT_ID integer primary key default nextval('ATTACHMENT_ID_SEQ'), -- implicit index
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ DROPBOX_ID varchar(255),
+ CONTENT_TYPE varchar(255) not null,
+ SIZE integer not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ PATH varchar(1024) not null
+);
+
+create index ATTACHMENT_CALENDAR_HOME_RESOURCE_ID on
+ ATTACHMENT(CALENDAR_HOME_RESOURCE_ID);
+
+-- Many-to-many relationship between attachments and calendar objects
+create table ATTACHMENT_CALENDAR_OBJECT (
+ ATTACHMENT_ID integer not null references ATTACHMENT on delete cascade,
+ MANAGED_ID varchar(255) not null,
+ CALENDAR_OBJECT_RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+
+ primary key (ATTACHMENT_ID, CALENDAR_OBJECT_RESOURCE_ID), -- implicit index
+ unique (MANAGED_ID, CALENDAR_OBJECT_RESOURCE_ID) --implicit index
+);
+
+
+-----------------------
+-- Resource Property --
+-----------------------
+
+create table RESOURCE_PROPERTY (
+ RESOURCE_ID integer not null, -- foreign key: *.RESOURCE_ID
+ NAME varchar(255) not null,
+ VALUE text not null, -- FIXME: xml?
+ VIEWER_UID varchar(255),
+
+ primary key (RESOURCE_ID, NAME, VIEWER_UID) -- implicit index
+);
+
+
+----------------------
+-- AddressBook Home --
+----------------------
+
+create table ADDRESSBOOK_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ OWNER_UID varchar(255) not null unique, -- implicit index
+ DATAVERSION integer default 0 not null
+);
+
+-------------------------------
+-- AddressBook Home Metadata --
+-------------------------------
+
+create table ADDRESSBOOK_HOME_METADATA (
+ RESOURCE_ID integer primary key references ADDRESSBOOK_HOME on delete cascade, -- implicit index
+ QUOTA_USED_BYTES integer default 0 not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+-----------------
+-- AddressBook --
+-----------------
+
+create table ADDRESSBOOK (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
+);
+
+
+--------------------------
+-- AddressBook Metadata --
+--------------------------
+
+create table ADDRESSBOOK_METADATA (
+ RESOURCE_ID integer primary key references ADDRESSBOOK on delete cascade, -- implicit index
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+----------------------
+-- AddressBook Bind --
+----------------------
+
+-- Joins ADDRESSBOOK_HOME and ADDRESSBOOK
+
+create table ADDRESSBOOK_BIND (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ ADDRESSBOOK_RESOURCE_ID integer not null references ADDRESSBOOK on delete cascade,
+
+ -- An invitation which hasn't been accepted yet will not yet have a resource
+ -- name, so this field may be null.
+
+ ADDRESSBOOK_RESOURCE_NAME varchar(255),
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ SEEN_BY_OWNER boolean not null,
+ SEEN_BY_SHAREE boolean not null,
+ MESSAGE text, -- FIXME: xml?
+
+ primary key (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_ID), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_NAME) -- implicit index
+);
+
+create index ADDRESSBOOK_BIND_RESOURCE_ID on
+ ADDRESSBOOK_BIND(ADDRESSBOOK_RESOURCE_ID);
+
+create table ADDRESSBOOK_OBJECT (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ ADDRESSBOOK_RESOURCE_ID integer not null references ADDRESSBOOK on delete cascade,
+ RESOURCE_NAME varchar(255) not null,
+ VCARD_TEXT text not null,
+ VCARD_UID varchar(255) not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (ADDRESSBOOK_RESOURCE_ID, RESOURCE_NAME), -- implicit index
+ unique (ADDRESSBOOK_RESOURCE_ID, VCARD_UID) -- implicit index
+);
+
+---------------
+-- Revisions --
+---------------
+
+create sequence REVISION_SEQ;
+
+
+---------------
+-- Revisions --
+---------------
+
+create table CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ CALENDAR_RESOURCE_ID integer references CALENDAR,
+ CALENDAR_NAME varchar(255) default null,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null
+);
+
+create index CALENDAR_OBJECT_REVISIONS_HOME_RESOURCE_ID_CALENDAR_RESOURCE_ID
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_RESOURCE_NAME
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, RESOURCE_NAME);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, REVISION);
+
+-------------------------------
+-- AddressBook Object Revisions --
+-------------------------------
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ ADDRESSBOOK_RESOURCE_ID integer references ADDRESSBOOK,
+ ADDRESSBOOK_NAME varchar(255) default null,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null
+);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_HOME_RESOURCE_ID_ADDRESSBOOK_RESOURCE_ID
+ on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_ID);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_RESOURCE_ID_RESOURCE_NAME
+ on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_RESOURCE_ID, RESOURCE_NAME);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+ on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_RESOURCE_ID, REVISION);
+
+-----------------------------------
+-- Notification Object Revisions --
+-----------------------------------
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+ NOTIFICATION_HOME_RESOURCE_ID integer not null references NOTIFICATION_HOME on delete cascade,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null,
+
+ unique(NOTIFICATION_HOME_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+);
+
+create index NOTIFICATION_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+ on NOTIFICATION_OBJECT_REVISIONS(NOTIFICATION_HOME_RESOURCE_ID, REVISION);
+
+-------------------------------------------
+-- Apple Push Notification Subscriptions --
+-------------------------------------------
+
+create table APN_SUBSCRIPTIONS (
+ TOKEN varchar(255) not null,
+ RESOURCE_KEY varchar(255) not null,
+ MODIFIED integer not null,
+ SUBSCRIBER_GUID varchar(255) not null,
+ USER_AGENT varchar(255) default null,
+ IP_ADDR varchar(255) default null,
+
+ primary key (TOKEN, RESOURCE_KEY) -- implicit index
+);
+
+create index APN_SUBSCRIPTIONS_RESOURCE_KEY
+ on APN_SUBSCRIPTIONS(RESOURCE_KEY);
+
+
+--------------------
+-- Schema Version --
+--------------------
+
+create table CALENDARSERVER (
+ NAME varchar(255) primary key, -- implicit index
+ VALUE varchar(255)
+);
+
+insert into CALENDARSERVER values ('VERSION', '13');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '3');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '1');
Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_13_to_14.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_13_to_14.sql (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_13_to_14.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -0,0 +1,33 @@
+----
+-- Copyright (c) 2012 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 13 to 14 --
+---------------------------------------------------
+
+-- sharing-related cleanup
+
+drop table INVITE;
+
+alter table CALENDAR_BIND
+ drop column SEEN_BY_OWNER, SEEN_BY_SHAREE;
+
+alter table ADDRESSBOOK_BIND
+ drop column SEEN_BY_OWNER, SEEN_BY_SHAREE;
+
+-- Now update the version
+-- No data upgrades
+update CALENDARSERVER set VALUE = '14' where NAME = 'VERSION';
Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_13_to_14.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_13_to_14.sql (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_13_to_14.sql 2012-12-12 16:37:28 UTC (rev 10158)
@@ -0,0 +1,37 @@
+----
+-- Copyright (c) 2012 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 13 to 14 --
+---------------------------------------------------
+
+-- sharing-related cleanup
+
+drop table INVITE;
+
+alter table CALENDAR_BIND
+ drop column SEEN_BY_OWNER;
+alter table CALENDAR_BIND
+ drop column SEEN_BY_SHAREE;
+
+alter table ADDRESSBOOK_BIND
+ drop column SEEN_BY_OWNER;
+alter table ADDRESSBOOK_BIND
+ drop column SEEN_BY_SHAREE;
+
+-- Now update the version
+-- No data upgrades
+update CALENDARSERVER set VALUE = '14' where NAME = 'VERSION';
Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/util.py 2012-12-12 02:30:18 UTC (rev 10157)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py 2012-12-12 16:37:28 UTC (rev 10158)
@@ -22,7 +22,7 @@
from hashlib import md5
from random import Random
from zope.interface.verify import verifyObject
-from zope.interface.exceptions import BrokenMethodImplementation,\
+from zope.interface.exceptions import BrokenMethodImplementation, \
DoesNotImplement
from twext.python.filepath import CachingFilePath
@@ -96,7 +96,7 @@
return PostgresService(
dbRoot, serviceFactory, current_sql_schema, resetSchema=True,
databaseName="caldav",
- options = [
+ options=[
"-c log_lock_waits=TRUE",
"-c log_statement=all",
"-c log_line_prefix='%p.%x '",
@@ -221,8 +221,7 @@
)
# TODO: should be getting these tables from a declaration of the schema
# somewhere.
- tables = ['INVITE',
- 'RESOURCE_PROPERTY',
+ tables = ['RESOURCE_PROPERTY',
'ATTACHMENT',
'NOTIFICATION_OBJECT_REVISIONS',
'ADDRESSBOOK_OBJECT_REVISIONS',
@@ -239,7 +238,7 @@
'NOTIFICATION_HOME']
for table in tables:
try:
- yield cleanupTxn.execSQL("delete from "+table, [])
+ yield cleanupTxn.execSQL("delete from " + table, [])
except:
log.err()
yield cleanupTxn.commit()
@@ -416,7 +415,7 @@
yield calendar.createCalendarObjectWithName(
objectName,
VComponent.fromString(updateToCurrentYear(objData)),
- metadata = metadata,
+ metadata=metadata,
)
yield populateTxn.commit()
@@ -425,7 +424,7 @@
"""
Update the supplied iCalendar data so that all dates are updated to the current year.
"""
-
+
nowYear = PyCalendarDateTime.getToday().getYear()
return data % {"now":nowYear}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121212/2916bcf0/attachment-0001.html>
More information about the calendarserver-changes
mailing list