Revision
9279
Author
glyph@apple.com
Date
2012-05-24 13:33:50 -0700 (Thu, 24 May 2012)

Log Message

dataversion upgrader that invokes the case-normalization logic

Modified Paths

Added Paths

Diff

Modified: CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/sql_schema/current.sql (9278 => 9279)


--- CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/sql_schema/current.sql	2012-05-24 20:33:47 UTC (rev 9278)
+++ CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/sql_schema/current.sql	2012-05-24 20:33:50 UTC (rev 9279)
@@ -495,5 +495,5 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '9');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '2');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '3');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '1');

Added: CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py (0 => 9279)


--- CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py	                        (rev 0)
+++ CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/upgrade/sql/upgrades/upgrade_from_2_to_3.py	2012-05-24 20:33:50 UTC (rev 9279)
@@ -0,0 +1,42 @@
+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+##
+# Copyright (c) 2011 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 fixCaseNormalization
+from twisted.internet.defer import inlineCallbacks
+from txdav.common.datastore.upgrade.sql.upgrades.util import updateDataVersion
+
+UPGRADE_TO_VERSION = 3
+
+@inlineCallbacks
+def doUpgrade(sqlStore):
+    """
+    Do the required upgrade steps.
+    """
+
+    yield fixCaseNormalization(sqlStore)
+
+    # Always bump the DB value
+    yield updateDataVersion(
+        sqlStore, "CALENDAR-DATAVERSION", UPGRADE_TO_VERSION
+    )
+