[CalendarServer-changes] [11103] CalendarServer/branches/users/gaya/sharedgroups-3
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 26 10:56:49 PDT 2013
Revision: 11103
http://trac.calendarserver.org//changeset/11103
Author: gaya at apple.com
Date: 2013-04-26 10:56:49 -0700 (Fri, 26 Apr 2013)
Log Message:
-----------
add addressbook data upgrade that's different from calendar data upgrade. Add stub schema upgrade.
Modified Paths:
--------------
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/caldav.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/current.sql
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrade.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/util.py
Added Paths:
-----------
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_18_to_19.sql
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_2_to_3.py
Removed Paths:
-------------
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_1_to_2.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/caldav.py 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/caldav.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -66,7 +66,7 @@
from txdav.common.datastore.sql_tables import schema
from txdav.common.datastore.upgrade.sql.upgrade import (
- UpgradeDatabaseSchemaService, UpgradeDatabaseDataService, UpgradeDatabaseOtherService,
+ UpgradeDatabaseSchemaService, UpgradeDatabaseCalendarDataService, UpgradeDatabaseAddressBookDataService, UpgradeDatabaseOtherService,
)
from txdav.common.datastore.upgrade.migrate import UpgradeToDatabaseService
@@ -1117,16 +1117,19 @@
upgradeSvc = UpgradeFileSystemFormatService(
config, spawner, parallel,
UpgradeDatabaseSchemaService.wrapService(
- UpgradeDatabaseDataService.wrapService(
- UpgradeToDatabaseService.wrapService(
- CachingFilePath(config.DocumentRoot),
- UpgradeDatabaseOtherService.wrapService(
- postImport,
+ UpgradeDatabaseCalendarDataService.wrapService(
+ UpgradeDatabaseAddressBookDataService.wrapService(
+ UpgradeToDatabaseService.wrapService(
+ CachingFilePath(config.DocumentRoot),
+ UpgradeDatabaseOtherService.wrapService(
+ postImport,
+ store, uid=overrideUID, gid=overrideGID,
+ ),
store, uid=overrideUID, gid=overrideGID,
+ spawner=spawner, merge=config.MergeUpgrades,
+ parallel=parallel
),
store, uid=overrideUID, gid=overrideGID,
- spawner=spawner, merge=config.MergeUpgrades,
- parallel=parallel
),
store, uid=overrideUID, gid=overrideGID,
),
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/current.sql
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/current.sql 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/current.sql 2013-04-26 17:56:49 UTC (rev 11103)
@@ -637,6 +637,6 @@
VALUE varchar(255)
);
-insert into CALENDARSERVER values ('VERSION', '18');
+insert into CALENDARSERVER values ('VERSION', '19');
insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '3');
-insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '1');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
Added: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_18_to_19.sql
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_18_to_19.sql (rev 0)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_18_to_19.sql 2013-04-26 17:56:49 UTC (rev 11103)
@@ -0,0 +1,25 @@
+----
+-- Copyright (c) 2011-2013 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 18 to 19 --
+---------------------------------------------------
+
+
+-- Now update the version
+-- FIXME: Do nothing now!
+update CALENDARSERVER set VALUE = '18' where NAME = 'VERSION';
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrade.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrade.py 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrade.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -1,5 +1,5 @@
# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
-##
+# #
# Copyright (c) 2010-2013 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,7 @@
# 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.
-##
+# #
"""
Utilities, mostly related to upgrading, common to calendar and addresbook
@@ -91,6 +91,7 @@
self.versionKey = None
self.versionDescriptor = ""
+ self.upgradeFilePrefix = ""
self.upgradeFileSuffix = ""
self.defaultKeyValue = None
@@ -214,8 +215,8 @@
fp = self.getPathToUpgrades(dialect)
upgrades = []
- regex = re.compile("upgrade_from_(\d+)_to_(\d+)%s" % (self.upgradeFileSuffix,))
- for child in fp.globChildren("upgrade_*%s" % (self.upgradeFileSuffix,)):
+ regex = re.compile("%supgrade_from_(\d+)_to_(\d+)%s" % (self.upgradeFilePrefix, self.upgradeFileSuffix,))
+ for child in fp.globChildren("%supgrade_*%s" % (self.upgradeFilePrefix, self.upgradeFileSuffix,)):
matched = regex.match(child.basename())
if matched is not None:
fromV = int(matched.group(1))
@@ -234,7 +235,6 @@
step. As a result we will always try and pick the upgrade file that gives the biggest
jump from one version to another at each step.
"""
-
# Now find the path from the old version to the current one
filesByFromVersion = {}
for fromV, toV, fp in files:
@@ -334,20 +334,7 @@
@type wrappedService: L{IService} or C{NoneType}
"""
- def __init__(self, sqlStore, service, **kwargs):
- """
- Initialize the service.
- @param sqlStore: The store to operate on. Can be C{None} when doing unit tests.
- @param service: Wrapped service. Can be C{None} when doing unit tests.
- """
- super(UpgradeDatabaseDataService, self).__init__(sqlStore, service, **kwargs)
-
- self.versionKey = "CALENDAR-DATAVERSION"
- self.versionDescriptor = "data"
- self.upgradeFileSuffix = ".py"
-
-
def getPathToUpgrades(self, dialect):
return self.pyLocation.child("upgrades")
@@ -358,6 +345,7 @@
Apply the data upgrade .py files to the database.
"""
+
# Find the module function we need to execute
try:
module = getModule(__name__)
@@ -373,6 +361,74 @@
+class UpgradeDatabaseCalendarDataService(UpgradeDatabaseDataService):
+ """
+ Checks and upgrades the database data. This assumes there are a bunch of
+ upgrade python modules that we can execute against the database to
+ accomplish the upgrade.
+
+ @ivar sqlStore: The store to operate on.
+
+ @type sqlStore: L{txdav.idav.IDataStore}
+
+ @ivar wrappedService: Wrapped L{IService} that will be started after this
+ L{UpgradeDatabaseSchemaService}'s work is done and the database schema
+ of C{sqlStore} is fully upgraded. This may also be specified as
+ C{None}, in which case no service will be started.
+
+ @type wrappedService: L{IService} or C{NoneType}
+ """
+
+ def __init__(self, sqlStore, service, **kwargs):
+ """
+ Initialize the service.
+
+ @param sqlStore: The store to operate on. Can be C{None} when doing unit tests.
+ @param service: Wrapped service. Can be C{None} when doing unit tests.
+ """
+ super(UpgradeDatabaseCalendarDataService, self).__init__(sqlStore, service, **kwargs)
+
+ self.versionKey = "CALENDAR-DATAVERSION"
+ self.versionDescriptor = "calendar data"
+ self.upgradeFilePrefix = "calendar_"
+ self.upgradeFileSuffix = ".py"
+
+
+
+class UpgradeDatabaseAddressBookDataService(UpgradeDatabaseDataService):
+ """
+ Checks and upgrades the database data. This assumes there are a bunch of
+ upgrade python modules that we can execute against the database to
+ accomplish the upgrade.
+
+ @ivar sqlStore: The store to operate on.
+
+ @type sqlStore: L{txdav.idav.IDataStore}
+
+ @ivar wrappedService: Wrapped L{IService} that will be started after this
+ L{UpgradeDatabaseSchemaService}'s work is done and the database schema
+ of C{sqlStore} is fully upgraded. This may also be specified as
+ C{None}, in which case no service will be started.
+
+ @type wrappedService: L{IService} or C{NoneType}
+ """
+
+ def __init__(self, sqlStore, service, **kwargs):
+ """
+ Initialize the service.
+
+ @param sqlStore: The store to operate on. Can be C{None} when doing unit tests.
+ @param service: Wrapped service. Can be C{None} when doing unit tests.
+ """
+ super(UpgradeDatabaseAddressBookDataService, self).__init__(sqlStore, service, **kwargs)
+
+ self.versionKey = "ADDRESSBOOK-DATAVERSION"
+ self.versionDescriptor = "addressbook data"
+ self.upgradeFilePrefix = "addressbook_"
+ self.upgradeFileSuffix = ".py"
+
+
+
class UpgradeDatabaseOtherService(UpgradeDatabaseCoreService):
"""
Do any other upgrade behaviors once all the schema, data, file migration upgraders
Added: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py (rev 0)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -0,0 +1,35 @@
+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+# #
+# Copyright (c) 2011-2013 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.
+# #
+
+from twisted.internet.defer import inlineCallbacks
+from txdav.common.datastore.upgrade.sql.upgrades.util import updateAddressBookDataVersion
+
+"""
+Data upgrade from database version 1 to 2
+"""
+
+UPGRADE_TO_VERSION = 2
+
+ at inlineCallbacks
+def doUpgrade(sqlStore):
+ """
+ Do the required upgrade steps.
+ """
+
+ # FIXME: do nothing for now!
+ # Always bump the DB value
+ yield updateAddressBookDataVersion(sqlStore, UPGRADE_TO_VERSION - 1)
Copied: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py (from rev 11088, CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_1_to_2.py)
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py (rev 0)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -0,0 +1,89 @@
+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+##
+# Copyright (c) 2011-2013 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.
+##
+
+from twext.enterprise.dal.syntax import Update
+from txdav.xml.parser import WebDAVDocument
+from twisted.internet.defer import inlineCallbacks
+from twistedcaldav import caldavxml
+from txdav.common.datastore.sql_tables import schema
+from txdav.common.datastore.upgrade.sql.upgrades.util import rowsForProperty,\
+ removeProperty, updateDataVersion, doToEachCalendarHomeNotAtVersion
+
+"""
+Data upgrade from database version 1 to 2
+"""
+
+UPGRADE_TO_VERSION = 2
+
+ at inlineCallbacks
+def doUpgrade(sqlStore):
+ """
+ Do the required upgrade steps.
+ """
+ yield moveSupportedComponentSetProperties(sqlStore)
+ yield splitCalendars(sqlStore)
+
+ # Always bump the DB value
+ yield updateDataVersion(sqlStore, "CALENDAR-DATAVERSION", UPGRADE_TO_VERSION)
+
+
+
+ at inlineCallbacks
+def moveSupportedComponentSetProperties(sqlStore):
+ """
+ Need to move all the CalDAV:supported-component-set properties in the
+ RESOURCE_PROPERTY table to the new CALENDAR_METADATA table column,
+ extracting the new format value from the XML property.
+ """
+
+ sqlTxn = sqlStore.newTransaction()
+ try:
+ rows = (yield rowsForProperty(sqlTxn, caldavxml.SupportedCalendarComponentSet))
+ for calendar_rid, value in rows:
+ prop = WebDAVDocument.fromString(value).root_element
+ supported_components = ",".join(sorted([comp.attributes["name"].upper() for comp in prop.children]))
+ meta = schema.CALENDAR_METADATA
+ yield Update(
+ {
+ meta.SUPPORTED_COMPONENTS : supported_components
+ },
+ Where=(meta.RESOURCE_ID == calendar_rid)
+ ).on(sqlTxn)
+
+ yield removeProperty(sqlTxn, caldavxml.SupportedCalendarComponentSet)
+ yield sqlTxn.commit()
+ except RuntimeError:
+ yield sqlTxn.abort()
+ raise
+
+
+
+ at inlineCallbacks
+def splitCalendars(sqlStore):
+ """
+ Split all calendars by component type.
+ """
+
+ @inlineCallbacks
+ def doIt(home):
+ """
+ Split each regular calendar in the home.
+ """
+ yield home.splitCalendars()
+
+ # Do this to each calendar home not already at version 2
+ yield doToEachCalendarHomeNotAtVersion(sqlStore, schema.CALENDAR_HOME, UPGRADE_TO_VERSION, doIt)
Copied: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_2_to_3.py (from rev 11088, CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py)
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_2_to_3.py (rev 0)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_2_to_3.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -0,0 +1,42 @@
+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+##
+# Copyright (c) 2011-2013 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 to deal with normalization of UUIDs in
+CALENDAR_HOME/ADDRESSBOOK_HOME/NOTIFICATION/APN_SUBSCRIPTIONS tables, as well
+as in calendar data and properties.
+"""
+
+from txdav.common.datastore.sql import fixUUIDNormalization
+from twisted.internet.defer import inlineCallbacks
+from txdav.common.datastore.upgrade.sql.upgrades.util import updateDataVersion
+
+UPGRADE_TO_VERSION = 3
+
+ at inlineCallbacks
+def doUpgrade(sqlStore):
+ """
+ Do the UUID-normalization upgrade if necessary and then bump the data
+ version to indicate that it's been done.
+ """
+ yield fixUUIDNormalization(sqlStore)
+
+ # Always bump the DB value
+ yield updateDataVersion(
+ sqlStore, "CALENDAR-DATAVERSION", UPGRADE_TO_VERSION
+ )
+
Deleted: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_1_to_2.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_1_to_2.py 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_1_to_2.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -1,89 +0,0 @@
-# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
-##
-# Copyright (c) 2011-2013 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.
-##
-
-from twext.enterprise.dal.syntax import Update
-from txdav.xml.parser import WebDAVDocument
-from twisted.internet.defer import inlineCallbacks
-from twistedcaldav import caldavxml
-from txdav.common.datastore.sql_tables import schema
-from txdav.common.datastore.upgrade.sql.upgrades.util import rowsForProperty,\
- removeProperty, updateDataVersion, doToEachCalendarHomeNotAtVersion
-
-"""
-Data upgrade from database version 1 to 2
-"""
-
-UPGRADE_TO_VERSION = 2
-
- at inlineCallbacks
-def doUpgrade(sqlStore):
- """
- Do the required upgrade steps.
- """
- yield moveSupportedComponentSetProperties(sqlStore)
- yield splitCalendars(sqlStore)
-
- # Always bump the DB value
- yield updateDataVersion(sqlStore, "CALENDAR-DATAVERSION", UPGRADE_TO_VERSION)
-
-
-
- at inlineCallbacks
-def moveSupportedComponentSetProperties(sqlStore):
- """
- Need to move all the CalDAV:supported-component-set properties in the
- RESOURCE_PROPERTY table to the new CALENDAR_METADATA table column,
- extracting the new format value from the XML property.
- """
-
- sqlTxn = sqlStore.newTransaction()
- try:
- rows = (yield rowsForProperty(sqlTxn, caldavxml.SupportedCalendarComponentSet))
- for calendar_rid, value in rows:
- prop = WebDAVDocument.fromString(value).root_element
- supported_components = ",".join(sorted([comp.attributes["name"].upper() for comp in prop.children]))
- meta = schema.CALENDAR_METADATA
- yield Update(
- {
- meta.SUPPORTED_COMPONENTS : supported_components
- },
- Where=(meta.RESOURCE_ID == calendar_rid)
- ).on(sqlTxn)
-
- yield removeProperty(sqlTxn, caldavxml.SupportedCalendarComponentSet)
- yield sqlTxn.commit()
- except RuntimeError:
- yield sqlTxn.abort()
- raise
-
-
-
- at inlineCallbacks
-def splitCalendars(sqlStore):
- """
- Split all calendars by component type.
- """
-
- @inlineCallbacks
- def doIt(home):
- """
- Split each regular calendar in the home.
- """
- yield home.splitCalendars()
-
- # Do this to each calendar home not already at version 2
- yield doToEachCalendarHomeNotAtVersion(sqlStore, UPGRADE_TO_VERSION, doIt)
Deleted: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -1,42 +0,0 @@
-# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
-##
-# Copyright (c) 2011-2013 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 to deal with normalization of UUIDs in
-CALENDAR_HOME/ADDRESSBOOK_HOME/NOTIFICATION/APN_SUBSCRIPTIONS tables, as well
-as in calendar data and properties.
-"""
-
-from txdav.common.datastore.sql import fixUUIDNormalization
-from twisted.internet.defer import inlineCallbacks
-from txdav.common.datastore.upgrade.sql.upgrades.util import updateDataVersion
-
-UPGRADE_TO_VERSION = 3
-
- at inlineCallbacks
-def doUpgrade(sqlStore):
- """
- Do the UUID-normalization upgrade if necessary and then bump the data
- version to indicate that it's been done.
- """
- yield fixUUIDNormalization(sqlStore)
-
- # Always bump the DB value
- yield updateDataVersion(
- sqlStore, "CALENDAR-DATAVERSION", UPGRADE_TO_VERSION
- )
-
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/util.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/util.py 2013-04-26 16:45:09 UTC (rev 11102)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/upgrade/sql/upgrades/util.py 2013-04-26 17:56:49 UTC (rev 11103)
@@ -60,9 +60,9 @@
return updateDataVersion(store, "ADDRESSBOOK-DATAVERSION", version)
@inlineCallbacks
-def doToEachCalendarHomeNotAtVersion(store, version, doIt):
+def doToEachCalendarHomeNotAtVersion(store, homeSchema, version, doIt):
"""
- Do something to each calendar home whose version column indicates it is older
+ Do something to each home whose version column indicates it is older
than the specified version. Do this in batches as there may be a lot of work to do.
"""
@@ -71,12 +71,11 @@
# Get the next home with an old version
txn = store.newTransaction("updateDataVersion")
try:
- ch = schema.CALENDAR_HOME
rows = yield Select(
- [ch.RESOURCE_ID, ch.OWNER_UID,],
- From=ch,
- Where=ch.DATAVERSION < version,
- OrderBy=ch.OWNER_UID,
+ [homeSchema.RESOURCE_ID, homeSchema.OWNER_UID, ],
+ From=homeSchema,
+ Where=homeSchema.DATAVERSION < version,
+ OrderBy=homeSchema.OWNER_UID,
Limit=1,
).on(txn)
@@ -91,8 +90,8 @@
# Update the home to the current version
yield Update(
- {ch.DATAVERSION: version},
- Where=ch.RESOURCE_ID == resource_id,
+ {homeSchema.DATAVERSION: version},
+ Where=homeSchema.RESOURCE_ID == resource_id,
).on(txn)
yield txn.commit()
except RuntimeError:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130426/954dc570/attachment-0001.html>
More information about the calendarserver-changes
mailing list