[CalendarServer-changes] [12800] CalendarServer/trunk/txdav/common/datastore

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 4 14:54:32 PST 2014


Revision: 12800
          http://trac.calendarserver.org//changeset/12800
Author:   cdaboo at apple.com
Date:     2014-03-04 14:54:32 -0800 (Tue, 04 Mar 2014)
Log Message:
-----------
Fix empty default alarms not set properly in an earlier upgrade.

Modified Paths:
--------------
    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/sql_schema/old/oracle-dialect/v28.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v30.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v31.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v32.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v33.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v34.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v30.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v31.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v32.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v33.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v34.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql
    CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql

Added Paths:
-----------
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -537,7 +537,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '37');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -1009,7 +1009,7 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '37');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -367,7 +367,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '28');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
     DEFAULT_EVENTS

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -368,7 +368,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '29');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
     DEFAULT_EVENTS

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v30.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v30.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v30.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -371,7 +371,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '30');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v31.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v31.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v31.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -374,7 +374,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '31');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v32.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v32.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v32.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -387,7 +387,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '32');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v33.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v33.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v33.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -401,7 +401,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '33');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v34.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v34.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v34.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -463,7 +463,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '34');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -516,7 +516,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '35');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -527,7 +527,7 @@
 );
 
 insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '36');
-insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -700,5 +700,5 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '28');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -703,5 +703,5 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '29');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v30.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v30.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v30.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -706,6 +706,6 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '30');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v31.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v31.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v31.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -715,6 +715,6 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '31');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v32.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v32.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v32.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -734,6 +734,6 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '32');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v33.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v33.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v33.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -752,7 +752,7 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '33');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v34.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v34.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v34.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -863,7 +863,7 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '34');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -923,7 +923,7 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '35');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');

Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql	2014-03-04 22:51:30 UTC (rev 12799)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql	2014-03-04 22:54:32 UTC (rev 12800)
@@ -938,7 +938,7 @@
 );
 
 insert into CALENDARSERVER values ('VERSION', '36');
-insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
 insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
 insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
 insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');

Added: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py	                        (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py	2014-03-04 22:54:32 UTC (rev 12800)
@@ -0,0 +1,53 @@
+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+##
+# Copyright (c) 2011-2014 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 twisted.internet.defer import inlineCallbacks
+
+from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
+from txdav.common.datastore.upgrade.sql.upgrades.util import updateCalendarDataVersion, \
+    updateAllCalendarHomeDataVersions
+
+"""
+Data upgrade from database version 5 to 6
+"""
+
+UPGRADE_TO_VERSION = 6
+
+ at inlineCallbacks
+def doUpgrade(sqlStore):
+    """
+    Do the required upgrade steps.
+    """
+
+    sqlTxn = sqlStore.newTransaction()
+    cb = schema.CALENDAR_BIND
+    yield Update(
+        {
+            cb.ALARM_VEVENT_TIMED: "empty",
+            cb.ALARM_VEVENT_ALLDAY: "empty",
+            cb.ALARM_VTODO_TIMED: "empty",
+            cb.ALARM_VTODO_ALLDAY: "empty",
+        },
+        Where=(cb.BIND_MODE != _BIND_MODE_OWN)
+    ).on(sqlTxn)
+    yield sqlTxn.commit()
+
+    # Always bump the DB value
+    yield updateAllCalendarHomeDataVersions(sqlStore, UPGRADE_TO_VERSION)
+    yield updateCalendarDataVersion(sqlStore, UPGRADE_TO_VERSION)

Added: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py	                        (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py	2014-03-04 22:54:32 UTC (rev 12800)
@@ -0,0 +1,140 @@
+##
+# Copyright (c) 2010-2014 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.
+##
+
+"""
+Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
+"""
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+from twext.enterprise.dal.syntax import Update
+
+from txdav.caldav.datastore.test.util import CommonStoreTests
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE, _BIND_MODE_READ
+from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_5_to_6 import doUpgrade
+
+
+class Upgrade_from_5_to_6(CommonStoreTests):
+    """
+    Tests for L{DefaultCalendarPropertyUpgrade}.
+    """
+
+    @inlineCallbacks
+    def _upgrade_setup(self):
+
+        # Setup old properties
+        detailshome = (
+            (True, True, "boo",),
+            (True, False, "boo",),
+            (False, True, "boo",),
+            (False, False, "boo",),
+        )
+        detailscalendar = (
+            (True, True, "boo",),
+            (True, False, "boo",),
+            (False, True, "boo",),
+            (False, False, "boo",),
+        )
+        detailsshared = (
+            (True, True, "",),
+            (True, False, "boo",),
+            (False, True, "boo",),
+            (False, False, "",),
+        )
+
+        home = yield self.homeUnderTest(name="user01")
+        for vevent, timed, alarm in detailshome:
+            yield home.setDefaultAlarm(alarm, vevent, timed)
+
+        calendar = yield self.calendarUnderTest(name="calendar_1", home="user01")
+        for vevent, timed, alarm in detailscalendar:
+            yield calendar.setDefaultAlarm(alarm, vevent, timed)
+
+        home2 = yield self.homeUnderTest(name="user02")
+        shared_name2 = yield calendar.shareWith(home2, _BIND_MODE_WRITE)
+        shared = yield self.calendarUnderTest(name=shared_name2, home="user02")
+        for vevent, timed, alarm in detailsshared:
+            yield shared.setDefaultAlarm(alarm, vevent, timed)
+
+        home3 = yield self.homeUnderTest(name="user03")
+        shared_name3 = yield calendar.shareWith(home3, _BIND_MODE_READ)
+        shared = yield self.calendarUnderTest(name=shared_name3, home="user03")
+        for vevent, timed, alarm in detailsshared:
+            yield shared.setDefaultAlarm(alarm, vevent, timed)
+
+        for user in ("user01", "user02", "user03",):
+            # Force data version to previous
+            home = (yield self.homeUnderTest(name=user))
+            ch = home._homeSchema
+            yield Update(
+                {ch.DATAVERSION: 5},
+                Where=ch.RESOURCE_ID == home._resourceID,
+            ).on(self.transactionUnderTest())
+
+        yield self.commit()
+
+        # Re-adjust for empty changes
+        detailsshared = (
+            (True, True, "empty",),
+            (True, False, "empty",),
+            (False, True, "empty",),
+            (False, False, "empty",),
+        )
+
+        returnValue((detailshome, detailscalendar, detailsshared, shared_name2, shared_name3,))
+
+
+    @inlineCallbacks
+    def _upgrade_check(self, detailshome, detailscalendar, detailsshared, shared_name2, shared_name3):
+
+        # Check each type of collection
+        home = yield self.homeUnderTest(name="user01")
+        version = (yield home.dataVersion())
+        self.assertEqual(version, 6)
+        for vevent, timed, alarm in detailshome:
+            alarm_result = (yield home.getDefaultAlarm(vevent, timed))
+            self.assertEquals(alarm_result, alarm)
+
+        calendar = yield self.calendarUnderTest(name="calendar_1", home="user01")
+        for vevent, timed, alarm in detailscalendar:
+            alarm_result = (yield calendar.getDefaultAlarm(vevent, timed))
+            self.assertEquals(alarm_result, alarm)
+
+        home2 = (yield self.homeUnderTest(name="user02"))
+        version = (yield home2.dataVersion())
+        self.assertEqual(version, 6)
+        shared = yield self.calendarUnderTest(name=shared_name2, home="user02")
+        for vevent, timed, alarm in detailsshared:
+            alarm_result = (yield shared.getDefaultAlarm(vevent, timed))
+            self.assertEquals(alarm_result, alarm)
+
+        home3 = (yield self.homeUnderTest(name="user02"))
+        version = (yield home3.dataVersion())
+        self.assertEqual(version, 6)
+        shared = yield self.calendarUnderTest(name=shared_name3, home="user03")
+        for vevent, timed, alarm in detailsshared:
+            alarm_result = (yield shared.getDefaultAlarm(vevent, timed))
+            self.assertEquals(alarm_result, alarm)
+
+        version = yield self.transactionUnderTest().calendarserverValue("CALENDAR-DATAVERSION")
+        self.assertEqual(int(version), 6)
+
+
+    @inlineCallbacks
+    def test_defaultAlarmUpgrade(self):
+        detailshome, detailscalendar, detailsshared, shared_name2, shared_name3 = (yield self._upgrade_setup())
+        yield doUpgrade(self._sqlCalendarStore)
+        yield self._upgrade_check(detailshome, detailscalendar, detailsshared, shared_name2, shared_name3)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140304/6fca657f/attachment-0001.html>


More information about the calendarserver-changes mailing list