<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14598] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14598">14598</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-03-15 20:04:19 -0700 (Sun, 15 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes to support Oracle DB unit testing. Fixes to Oracle schema upgrades.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkrequirementsstabletxt">CalendarServer/trunk/requirements-stable.txt</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_dumppy">CalendarServer/trunk/txdav/common/datastore/sql_dump.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv10sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v10.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv11sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v11.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv12sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v12.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv13sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv3sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v3.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv35sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv36sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv37sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v37.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv38sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v38.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv39sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v39.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv4sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v4.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv40sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v40.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv41sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv42sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v42.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv43sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv49sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v49.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv5sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v5.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv50sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v50.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv51sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v51.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv52sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v52.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv6sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v6.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv7sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v7.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv8sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v8.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv9sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v9.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_15_to_16sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_15_to_16.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_19_to_20sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_23_to_24sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_23_to_24.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_30_to_31sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_30_to_31.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_36_to_37sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_36_to_37.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_41_to_42sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_43_to_44sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_45_to_46sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_48_to_49sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_48_to_49.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_49_to_50sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_49_to_50.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_4_to_5sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_4_to_5.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_51_to_52sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_52_to_53sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_52_to_53.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretesttest_sql_dumppy">CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretestutilpy">CalendarServer/trunk/txdav/common/datastore/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradesqltesttest_upgradepy">CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavbasedatastoresuboraclepy">CalendarServer/trunk/txdav/base/datastore/suboracle.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretesttest_oracle_sqlpy">CalendarServer/trunk/txdav/common/datastore/test/test_oracle_sql.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkrequirementsstabletxt"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/requirements-stable.txt (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/requirements-stable.txt        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/requirements-stable.txt        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx">             #pyOpenSSL
</span><span class="cx">         pycrypto==2.6.1
</span><span class="cx"> 
</span><del>-    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@14586#egg=twextpy
</del><ins>+    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@14597#egg=twextpy
</ins><span class="cx">         cffi==0.8.6
</span><span class="cx">             pycparser==2.10
</span><span class="cx">         #twisted
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -421,7 +421,7 @@
</span><span class="cx">         &quot;LabelsInSQL&quot;            : False,
</span><span class="cx">         &quot;Statistics&quot;             : False,
</span><span class="cx">         &quot;StatisticsLogFile&quot;      : &quot;sqlstats.log&quot;,
</span><del>-        &quot;SQLStatements&quot;          : False,
</del><ins>+        &quot;SQLStatements&quot;          : True,
</ins><span class="cx">         &quot;TransactionWaitSeconds&quot; : 0,
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavbasedatastoresuboraclepy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/base/datastore/suboracle.py (0 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/base/datastore/suboracle.py                                (rev 0)
+++ CalendarServer/trunk/txdav/base/datastore/suboracle.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -0,0 +1,157 @@
</span><ins>+# -*- test-case-name: txdav.base.datastore.test.test_subpostgres -*-
+# #
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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
+
+&quot;&quot;&quot;
+Stub service for Oracle.
+&quot;&quot;&quot;
+
+from twext.python.log import Logger
+
+from txdav.base.datastore.dbapiclient import OracleConnector
+from txdav.common.icommondatastore import InternalDataStoreError
+
+from twisted.application.service import MultiService
+
+log = Logger()
+
+
+
+class OracleService(MultiService):
+
+    def __init__(
+        self, dataStoreDirectory, subServiceFactory,
+        dsnUser=None,
+        testMode=False,
+        reactor=None,
+    ):
+        &quot;&quot;&quot;
+        Initialize a L{OracleService} pointed at a data store directory.
+
+        @param dataStoreDirectory: the directory to
+        @type dataStoreDirectory: L{twext.python.filepath.CachingFilePath}
+
+        @param subServiceFactory: a 1-arg callable that will be called with a
+            1-arg callable which returns a DB-API cursor.
+        @type subServiceFactory: C{callable}
+        &quot;&quot;&quot;
+
+        MultiService.__init__(self)
+        self.subServiceFactory = subServiceFactory
+        self.dataStoreDirectory = dataStoreDirectory
+        self.workingDir = self.dataStoreDirectory.child(&quot;working&quot;)
+
+        self.dsnUser = dsnUser
+        self.testMode = testMode
+
+        self._reactor = reactor
+
+
+    @property
+    def reactor(self):
+        if self._reactor is None:
+            from twisted.internet import reactor
+            self._reactor = reactor
+        return self._reactor
+
+
+    def _connectorFor(self):
+        m = getattr(self, &quot;_connectorFor_{}&quot;.format(&quot;cx_oracle&quot;), None)
+        if m is None:
+            raise InternalDataStoreError(
+                &quot;Unknown Oracle DBM module: {}&quot;.format(&quot;cx_oracle&quot;)
+            )
+
+        return m()
+
+
+    def _connectorFor_cx_oracle(self):
+        dsn = &quot;{}/oracle@192.168.56.101:1521/orcl&quot;.format(self.dsnUser if self.dsnUser else &quot;hr&quot;)
+
+        log.info(
+            &quot;Connecting to Oracle with dsn={dsn!r}&quot;,
+            dsn=dsn,
+        )
+
+        return OracleConnector(dsn)
+
+
+    def produceConnection(self, label=&quot;&lt;unlabeled&gt;&quot;):
+        &quot;&quot;&quot;
+        Produce a DB-API 2.0 connection pointed at this database.
+        &quot;&quot;&quot;
+        return self._connectorFor().connect(label)
+
+
+    def pauseMonitor(self):
+        &quot;&quot;&quot;
+        Pause monitoring.
+        &quot;&quot;&quot;
+        pass
+
+
+    def unpauseMonitor(self):
+        &quot;&quot;&quot;
+        Unpause monitoring.
+
+        @see: L{pauseMonitor}
+        &quot;&quot;&quot;
+        pass
+
+
+    def startService(self):
+        MultiService.startService(self)
+
+        if not self.dataStoreDirectory.isdir():
+            log.info(&quot;Creating {dir}&quot;, dir=self.dataStoreDirectory.path)
+            self.dataStoreDirectory.createDirectory()
+
+        if not self.workingDir.isdir():
+            log.info(&quot;Creating {dir}&quot;, dir=self.workingDir.path)
+            self.workingDir.createDirectory()
+
+        self.subServiceFactory(
+            self.produceConnection, self
+        ).setServiceParent(self)
+
+
+    def hardStop(self):
+        &quot;&quot;&quot;
+        Stop quickly by sending it SIGQUIT
+        &quot;&quot;&quot;
+        pass
+
+
+
+@inlineCallbacks
+def cleanDatabase(txn):
+    tables = yield txn.execSQL(&quot;select table_name from user_tables&quot;)
+    for table in tables:
+        yield txn.execSQL(&quot;drop table {} cascade constraints purge&quot;.format(table[0]))
+    yield txn.execSQL(&quot;purge recyclebin&quot;)
+
+    sequences = yield txn.execSQL(&quot;select sequence_name from user_sequences&quot;)
+    for sequence in sequences:
+        yield txn.execSQL(&quot;drop sequence {}&quot;.format(sequence[0]))
+
+    indexes = yield txn.execSQL(&quot;select index_name from user_indexes&quot;)
+    for index in indexes:
+        yield txn.execSQL(&quot;drop index {}&quot;.format(index[0]))
+
+    constraints = yield txn.execSQL(&quot;select constraint_name from user_constraints&quot;)
+    for constraint in constraints:
+        yield txn.execSQL(&quot;drop constraint '{}'&quot;.format(constraint[0]))
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -973,7 +973,8 @@
</span><span class="cx">         for regular SQL operations - only upgrades.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         for stmt in splitSQLString(sql):
</span><del>-            yield self.execSQL(stmt)
</del><ins>+            if not stmt.startswith(&quot;--&quot;):
+                yield self.execSQL(stmt)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def commit(self):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_dumppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_dump.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_dump.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_dump.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -17,32 +17,56 @@
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twext.enterprise.dal.model import Schema, Table, Column, Sequence, Function, \
</span><del>-    SQLType, ProcedureCall, Constraint
</del><ins>+    SQLType, ProcedureCall, Constraint, Index
</ins><span class="cx"> from twext.enterprise.dal.parseschema import addSQLToSchema
</span><ins>+from twext.enterprise.ienterprise import POSTGRES_DIALECT, ORACLE_DIALECT
+import collections
</ins><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Dump a postgres DB into an L{Schema} model object.
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-DTYPE_MAP = {
</del><ins>+DTYPE_MAP_POSTGRES = {
</ins><span class="cx">     &quot;character&quot;: &quot;char&quot;,
</span><span class="cx">     &quot;character varying&quot;: &quot;varchar&quot;,
</span><span class="cx">     &quot;timestamp without time zone&quot;: &quot;timestamp&quot;,
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DEFAULTVALUE_MAP = {
</del><ins>+DTYPE_MAP_ORACLE = {
+    &quot;number&quot;: &quot;integer&quot;,
+    &quot;timestamp(6)&quot;: &quot;timestamp&quot;,
+}
+
+DEFAULTVALUE_MAP_POSTGRES = {
</ins><span class="cx">     &quot;timezone('UTC'::text, now())&quot;: ProcedureCall(&quot;timezone&quot;, [&quot;UTC&quot;, &quot;CURRENT_TIMESTAMP&quot;]),
</span><span class="cx">     &quot;NULL::character varying&quot;: None,
</span><span class="cx">     &quot;false&quot;: False,
</span><span class="cx">     &quot;true&quot;: True,
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-@inlineCallbacks
</del><ins>+DEFAULTVALUE_MAP_ORACLE = {
+    &quot;CURRENT_TIMESTAMP at time zone 'UTC'&quot;: ProcedureCall(&quot;timezone&quot;, [&quot;UTC&quot;, &quot;CURRENT_TIMESTAMP&quot;]),
+    &quot;null&quot;: None,
+}
+
</ins><span class="cx"> def dumpSchema(txn, title, schemaname=&quot;public&quot;):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Generate the L{Schema}.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><ins>+    if txn.dialect == POSTGRES_DIALECT:
+        return dumpSchema_postgres(txn, title, schemaname)
+    elif txn.dialect == ORACLE_DIALECT:
+        return dumpSchema_oracle(txn, title, schemaname)
+
+
+
+@inlineCallbacks
+def dumpSchema_postgres(txn, title, schemaname=&quot;public&quot;):
+    &quot;&quot;&quot;
+    Generate the L{Schema}.
+    &quot;&quot;&quot;
+
</ins><span class="cx">     schemaname = schemaname.lower()
</span><span class="cx"> 
</span><span class="cx">     schema = Schema(title)
</span><span class="lines">@@ -66,14 +90,14 @@
</span><span class="cx">         rows = yield txn.execSQL(&quot;select column_name, data_type, is_nullable, character_maximum_length, column_default from information_schema.columns where table_schema = '%s' and table_name = '%s';&quot; % (schemaname, name,))
</span><span class="cx">         for name, datatype, is_nullable, charlen, default in rows:
</span><span class="cx">             # TODO: figure out the type
</span><del>-            column = Column(table, name.upper(), SQLType(DTYPE_MAP.get(datatype, datatype), charlen))
</del><ins>+            column = Column(table, name.upper(), SQLType(DTYPE_MAP_POSTGRES.get(datatype, datatype), charlen))
</ins><span class="cx">             table.columns.append(column)
</span><span class="cx">             if default:
</span><span class="cx">                 if default.startswith(&quot;nextval(&quot;):
</span><span class="cx">                     dname = default.split(&quot;'&quot;)[1].split(&quot;.&quot;)[-1]
</span><span class="cx">                     column.default = seqs[dname.upper()]
</span><del>-                elif default in DEFAULTVALUE_MAP:
-                    column.default = DEFAULTVALUE_MAP[default]
</del><ins>+                elif default in DEFAULTVALUE_MAP_POSTGRES:
+                    column.default = DEFAULTVALUE_MAP_POSTGRES[default]
</ins><span class="cx">                 else:
</span><span class="cx">                     try:
</span><span class="cx">                         column.default = int(default)
</span><span class="lines">@@ -116,3 +140,92 @@
</span><span class="cx">         Function(schema, name)
</span><span class="cx"> 
</span><span class="cx">     returnValue(schema)
</span><ins>+
+
+
+@inlineCallbacks
+def dumpSchema_oracle(txn, title, schemaname=&quot;public&quot;):
+    &quot;&quot;&quot;
+    Generate the L{Schema}.
+    &quot;&quot;&quot;
+
+    schemaname = schemaname.lower()
+
+    schema = Schema(title)
+
+    # Sequences
+    seqs = {}
+    rows = yield txn.execSQL(&quot;select sequence_name from all_sequences where sequence_owner = '%s'&quot; % (schemaname.upper(),))
+    for row in rows:
+        name = row[0]
+        seqs[name.upper()] = Sequence(schema, name.upper())
+
+    # Tables
+    tables = {}
+    rows = yield txn.execSQL(&quot;select table_name from all_tables where owner = '%s'&quot; % (schemaname.upper(),))
+    for row in rows:
+        name = row[0]
+        table = Table(schema, name.upper())
+        tables[name.upper()] = table
+
+        # Columns
+        rows = yield txn.execSQL(&quot;select column_name, data_type, nullable, char_length, data_default from all_tab_columns where owner = '%s' and table_name = '%s'&quot; % (schemaname.upper(), name,))
+        for name, datatype, is_nullable, charlen, default in rows:
+            # TODO: figure out the type
+            column = Column(table, name.upper(), SQLType(DTYPE_MAP_ORACLE.get(datatype.lower(), datatype.lower()), charlen))
+            table.columns.append(column)
+            if default:
+                default = default.strip()
+                if default.startswith(&quot;nextval(&quot;):
+                    dname = default.split(&quot;'&quot;)[1].split(&quot;.&quot;)[-1]
+                    column.default = seqs[dname.upper()]
+                elif default in DEFAULTVALUE_MAP_ORACLE:
+                    column.default = DEFAULTVALUE_MAP_ORACLE[default]
+                else:
+                    try:
+                        column.default = int(default)
+                    except ValueError:
+                        column.default = default
+            if is_nullable == &quot;N&quot;:
+                table.tableConstraint(Constraint.NOT_NULL, [column.name, ])
+
+    # Constraints
+    constraints = collections.defaultdict(list)
+    rows = yield txn.execSQL(&quot;select constraint_name, table_name, column_name, position from all_cons_columns where owner = '%s'&quot; % (schemaname.upper(),))
+    for conname, tname, cname, position in rows:
+        constraints[conname].append((tname, cname, position,))
+    rows = yield txn.execSQL(&quot;select constraint_name, constraint_type, table_name, r_constraint_name, delete_rule from all_constraints where owner = '%s'&quot; % (schemaname.upper(),))
+    for conname, conntype, tname, r_constraint_name, delete_rule in rows:
+        if constraints[conname][0][0].upper() in tables:
+            constraint = constraints[conname]
+            constraint = sorted(constraint, key=lambda x: x[2])
+            table = tables[constraint[0][0].upper()]
+            column_names = [item[1].upper() for item in constraint]
+            columns = [table.columnNamed(column_name) for column_name in column_names]
+            if conntype == &quot;P&quot;:
+                table.primaryKey = columns
+            elif conntype == &quot;U&quot;:
+                table.tableConstraint(Constraint.UNIQUE, column_names)
+            elif conntype == &quot;R&quot;:
+                columns[0].doesReferenceName(constraints[r_constraint_name][0][0].upper())
+                if delete_rule.lower() != &quot;no action&quot;:
+                    columns[0].deleteAction = delete_rule.lower()
+
+    # Indexed columns
+    idx = collections.defaultdict(list)
+    rows = yield txn.execSQL(&quot;select index_name, column_name, column_position from all_ind_columns where index_owner = '%s'&quot; % (schemaname.upper(),))
+    for index_name, column_name, column_position in rows:
+        idx[index_name].append((column_name, column_position))
+
+    # Indexes
+    rows = yield txn.execSQL(&quot;select index_name, table_name, uniqueness from all_indexes where owner = '%s'&quot; % (schemaname.upper(),))
+    for index_name, table_name, uniqueness in rows:
+        if table_name in tables:
+            table = tables[table_name]
+            column_names = [item[0].upper() for item in sorted(idx[index_name], key=lambda x: x[1])]
+            columns = [table.columnNamed(column_name) for column_name in column_names]
+            index = Index(schema, index_name.upper(), table, uniqueness == &quot;UNIQUE&quot;)
+            for column in columns:
+                index.addColumn(column)
+
+    returnValue(schema)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv10sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v10.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v10.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v10.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -265,14 +265,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv11sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v11.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v11.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v11.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -267,14 +267,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv12sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v12.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v12.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v12.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -275,14 +275,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv13sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v13.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -284,14 +284,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv3sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v3.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v3.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v3.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -237,9 +237,6 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '3');
</span><del>-create index CALENDAR_HOME_OWNER_U_78016c63 on CALENDAR_HOME (
-    OWNER_UID
-);
</del><span class="cx"> 
</span><span class="cx"> create index CALENDAR_HOME_METADAT_35a84eec on CALENDAR_HOME_METADATA (
</span><span class="cx">     RESOURCE_ID
</span><span class="lines">@@ -249,18 +246,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    INVITE_UID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    INVITE_UID
-);
-
-create index NOTIFICATION_HOME_OWN_401a6203 on NOTIFICATION_HOME (
-    OWNER_UID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span><span class="lines">@@ -315,10 +300,6 @@
</span><span class="cx">     DROPBOX_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index ADDRESSBOOK_HOME_OWNE_44f7f53b on ADDRESSBOOK_HOME (
-    OWNER_UID
-);
-
</del><span class="cx"> create index ADDRESSBOOK_HOME_META_cfe06701 on ADDRESSBOOK_HOME_METADATA (
</span><span class="cx">     RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv35sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -651,7 +651,7 @@
</span><span class="cx">     TOKEN
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUPS_GROUP_UID_ebf7a1d4 on GROUPS (
</del><ins>+create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
</ins><span class="cx">     GROUP_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv36sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -662,7 +662,7 @@
</span><span class="cx">     TOKEN
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUPS_GROUP_UID_ebf7a1d4 on GROUPS (
</del><ins>+create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
</ins><span class="cx">     GROUP_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv37sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v37.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v37.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v37.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -803,17 +803,3 @@
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv38sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v38.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v38.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v38.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -834,17 +834,3 @@
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv39sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v39.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v39.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v39.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -834,17 +834,3 @@
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv4sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v4.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v4.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v4.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -237,9 +237,6 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '4');
</span><del>-create index CALENDAR_HOME_OWNER_U_78016c63 on CALENDAR_HOME (
-    OWNER_UID
-);
</del><span class="cx"> 
</span><span class="cx"> create index CALENDAR_HOME_METADAT_35a84eec on CALENDAR_HOME_METADATA (
</span><span class="cx">     RESOURCE_ID
</span><span class="lines">@@ -249,18 +246,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    INVITE_UID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    INVITE_UID
-);
-
-create index NOTIFICATION_HOME_OWN_401a6203 on NOTIFICATION_HOME (
-    OWNER_UID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span><span class="lines">@@ -315,10 +300,6 @@
</span><span class="cx">     DROPBOX_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index ADDRESSBOOK_HOME_OWNE_44f7f53b on ADDRESSBOOK_HOME (
-    OWNER_UID
-);
-
</del><span class="cx"> create index ADDRESSBOOK_HOME_META_cfe06701 on ADDRESSBOOK_HOME_METADATA (
</span><span class="cx">     RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv40sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v40.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v40.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v40.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -836,18 +836,3 @@
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-declare
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv41sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -851,18 +851,3 @@
</span><span class="cx">     HOME_RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-declare
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv42sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v42.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v42.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v42.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -852,18 +852,3 @@
</span><span class="cx">     HOME_RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-declare
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv43sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -853,18 +853,3 @@
</span><span class="cx">     HOME_RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>--- Skipped Function next_job
-
--- Extras
-
-create or replace function next_job return integer is
-declare
-  cursor c1 is select JOB_ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select JOB_ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv49sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v49.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v49.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v49.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -904,7 +904,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_CHECK_198388a5 on PRINCIPAL_PURGE_CHECK_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
</span><span class="lines">@@ -912,7 +912,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__db35cfdc on PRINCIPAL_PURGE_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv5sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v5.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v5.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v5.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -239,14 +239,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv50sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v50.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v50.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v50.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -894,7 +894,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_CHECK_198388a5 on PRINCIPAL_PURGE_CHECK_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
</span><span class="lines">@@ -902,7 +902,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__db35cfdc on PRINCIPAL_PURGE_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv51sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v51.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v51.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v51.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -908,7 +908,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_CHECK_198388a5 on PRINCIPAL_PURGE_CHECK_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
</span><span class="lines">@@ -916,7 +916,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__db35cfdc on PRINCIPAL_PURGE_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
</span><span class="lines">@@ -926,5 +926,3 @@
</span><span class="cx"> create index PRINCIPAL_PURGE_HOME__967e4480 on PRINCIPAL_PURGE_HOME_WORK (
</span><span class="cx">     HOME_RESOURCE_ID
</span><span class="cx"> );
</span><del>-
--- Extra schema to add to current-oracle-dialect.sql
</del></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv52sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v52.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v52.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v52.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -957,7 +957,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_CHECK_198388a5 on PRINCIPAL_PURGE_CHECK_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
</span><span class="lines">@@ -965,7 +965,7 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__db35cfdc on PRINCIPAL_PURGE_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv6sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v6.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v6.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v6.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -247,14 +247,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv7sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v7.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v7.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v7.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -256,14 +256,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv8sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v8.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v8.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v8.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -264,14 +264,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv9sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v9.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v9.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v9.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -264,14 +264,6 @@
</span><span class="cx">     INVITE_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index INVITE_RESOURCE_ID_b36ddc23 on INVITE (
-    RESOURCE_ID
-);
-
-create index INVITE_HOME_RESOURCE__e9bdf77e on INVITE (
-    HOME_RESOURCE_ID
-);
-
</del><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span><span class="cx">     NOTIFICATION_HOME_RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_15_to_16sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_15_to_16.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_15_to_16.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_15_to_16.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -30,6 +30,10 @@
</span><span class="cx">     primary key(&quot;ORGANIZER&quot;, &quot;ATTENDEE&quot;, &quot;ICALUID&quot;)
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create index IMIP_TOKENS_TOKEN_e94b918f on IMIP_TOKENS (
+    TOKEN
+);
+
</ins><span class="cx"> create table IMIP_INVITATION_WORK (
</span><span class="cx">     &quot;WORK_ID&quot; integer primary key not null,
</span><span class="cx">     &quot;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_19_to_20sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -231,6 +231,9 @@
</span><span class="cx">                          )
</span><span class="cx">           );
</span><span class="cx"> 
</span><ins>+drop index ADDRESSBOOK_OBJECT_RE_f460d62d;
+drop index ADDRESSBOOK_OBJECT_RE_9a848f39;
+drop index ADDRESSBOOK_OBJECT_RE_cb101e6b;
</ins><span class="cx"> alter table ADDRESSBOOK_OBJECT_REVISIONS
</span><span class="cx">         drop (&quot;ADDRESSBOOK_RESOURCE_ID&quot;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_23_to_24sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_23_to_24.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_23_to_24.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_23_to_24.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx">     RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+alter index ADDRESSBOOK_OBJECT_RE_40cc2d73 rename to ADDRESSBOOK_OBJECT_RE_2bfcf757;
+
</ins><span class="cx"> -- Now update the version
</span><span class="cx"> -- No data upgrades
</span><span class="cx"> update CALENDARSERVER set VALUE = '24' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_30_to_31sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_30_to_31.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_30_to_31.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_30_to_31.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -22,6 +22,8 @@
</span><span class="cx"> -- Change Address Book Object Members --
</span><span class="cx"> ----------------------------------------
</span><span class="cx"> 
</span><ins>+alter table ABO_MEMBERS
+         drop primary key;
</ins><span class="cx"> begin
</span><span class="cx">     for i in (select constraint_name
</span><span class="cx">               from   user_cons_columns
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_36_to_37sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_36_to_37.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_36_to_37.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_36_to_37.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -33,22 +33,11 @@
</span><span class="cx">     &quot;NOT_AFTER&quot; timestamp default null
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create or replace function next_job return integer is
-  cursor c1 is select ID from JOB for update skip locked;
-  result integer;
-begin
-  open c1;
-  fetch c1 into result;
-  select ID from JOB where ID = result for update;
-  return result;
-end;
-/
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> -- IMIP_INVITATION_WORK --
</span><span class="cx"> alter table IMIP_INVITATION_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update IMIP_INVITATION_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update IMIP_INVITATION_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -57,7 +46,7 @@
</span><span class="cx"> alter table IMIP_INVITATION_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table IMIP_INVITATION_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index IMIP_INVITATION_WORK__586d064c on IMIP_INVITATION_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -67,7 +56,7 @@
</span><span class="cx"> -- IMIP_POLLING_WORK --
</span><span class="cx"> alter table IMIP_POLLING_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update IMIP_POLLING_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update IMIP_POLLING_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -76,7 +65,7 @@
</span><span class="cx"> alter table IMIP_POLLING_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table IMIP_POLLING_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index IMIP_POLLING_WORK_JOB_d5535891 on IMIP_POLLING_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -86,7 +75,7 @@
</span><span class="cx"> -- IMIP_REPLY_WORK --
</span><span class="cx"> alter table IMIP_REPLY_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update IMIP_REPLY_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update IMIP_REPLY_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -95,7 +84,7 @@
</span><span class="cx"> alter table IMIP_REPLY_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table IMIP_REPLY_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index IMIP_REPLY_WORK_JOB_I_bf4ae73e on IMIP_REPLY_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -105,7 +94,9 @@
</span><span class="cx"> -- PUSH_NOTIFICATION_WORK --
</span><span class="cx"> alter table PUSH_NOTIFICATION_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update PUSH_NOTIFICATION_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update PUSH_NOTIFICATION_WORK set JOB_ID = JOB_SEQ.nextval;
+alter table PUSH_NOTIFICATION_WORK
+    rename column &quot;PRIORITY&quot; to &quot;PUSH_PRIORITY&quot;;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -114,7 +105,7 @@
</span><span class="cx"> alter table PUSH_NOTIFICATION_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table PUSH_NOTIFICATION_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index PUSH_NOTIFICATION_WOR_8bbab117 on PUSH_NOTIFICATION_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -124,7 +115,7 @@
</span><span class="cx"> -- GROUP_CACHER_POLLING_WORK --
</span><span class="cx"> alter table GROUP_CACHER_POLLING_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update GROUP_CACHER_POLLING_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update GROUP_CACHER_POLLING_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -133,7 +124,7 @@
</span><span class="cx"> alter table GROUP_CACHER_POLLING_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table GROUP_CACHER_POLLING_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index GROUP_CACHER_POLLING__6eb3151c on GROUP_CACHER_POLLING_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -143,7 +134,7 @@
</span><span class="cx"> -- GROUP_REFRESH_WORK --
</span><span class="cx"> alter table GROUP_REFRESH_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update GROUP_REFRESH_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update GROUP_REFRESH_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -152,28 +143,28 @@
</span><span class="cx"> alter table GROUP_REFRESH_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table GROUP_REFRESH_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index GROUP_REFRESH_WORK_JO_717ede20 on GROUP_REFRESH_WORK (
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>--- GROUP_ATTENDEE_RECONCILIATION_WORK --
-alter table GROUP_ATTENDEE_RECONCILIATION_WORK
</del><ins>+-- GROUP_ATTENDEE_RECONCILIATION_ --
+alter table GROUP_ATTENDEE_RECONCILIATION_
</ins><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update GROUP_ATTENDEE_RECONCILIATION_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update GROUP_ATTENDEE_RECONCILIATION_ set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><del>-  (select JOB_ID, 'GROUP_ATTENDEE_RECONCILIATION_WORK', NOT_BEFORE from GROUP_ATTENDEE_RECONCILIATION_WORK);
</del><ins>+  (select JOB_ID, 'GROUP_ATTENDEE_RECONCILIATION_', NOT_BEFORE from GROUP_ATTENDEE_RECONCILIATION_);
</ins><span class="cx"> 
</span><del>-alter table GROUP_ATTENDEE_RECONCILIATION_WORK
</del><ins>+alter table GROUP_ATTENDEE_RECONCILIATION_
</ins><span class="cx">     drop column NOT_BEFORE;
</span><del>-alter table GROUP_ATTENDEE_RECONCILIATION_WORK
-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+alter table GROUP_ATTENDEE_RECONCILIATION_
+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><del>-create index GROUP_ATTENDEE_RECONC_cd2d61b9 on GROUP_ATTENDEE_RECONCILIATION_WORK (
</del><ins>+create index GROUP_ATTENDEE_RECONC_cd2d61b9 on GROUP_ATTENDEE_RECONCILIATION_ (
</ins><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -181,7 +172,7 @@
</span><span class="cx"> -- CALENDAR_OBJECT_SPLITTER_WORK --
</span><span class="cx"> alter table CALENDAR_OBJECT_SPLITTER_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update CALENDAR_OBJECT_SPLITTER_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update CALENDAR_OBJECT_SPLITTER_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -190,7 +181,7 @@
</span><span class="cx"> alter table CALENDAR_OBJECT_SPLITTER_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table CALENDAR_OBJECT_SPLITTER_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index CALENDAR_OBJECT_SPLIT_33603b72 on CALENDAR_OBJECT_SPLITTER_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -200,7 +191,7 @@
</span><span class="cx"> -- FIND_MIN_VALID_REVISION_WORK --
</span><span class="cx"> alter table FIND_MIN_VALID_REVISION_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update FIND_MIN_VALID_REVISION_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update FIND_MIN_VALID_REVISION_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -209,7 +200,7 @@
</span><span class="cx"> alter table FIND_MIN_VALID_REVISION_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table FIND_MIN_VALID_REVISION_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index FIND_MIN_VALID_REVISI_78d17400 on FIND_MIN_VALID_REVISION_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -219,7 +210,7 @@
</span><span class="cx"> -- REVISION_CLEANUP_WORK --
</span><span class="cx"> alter table REVISION_CLEANUP_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update REVISION_CLEANUP_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update REVISION_CLEANUP_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -228,7 +219,7 @@
</span><span class="cx"> alter table REVISION_CLEANUP_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table REVISION_CLEANUP_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index REVISION_CLEANUP_WORK_eb062686 on REVISION_CLEANUP_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -238,7 +229,7 @@
</span><span class="cx"> -- INBOX_CLEANUP_WORK --
</span><span class="cx"> alter table INBOX_CLEANUP_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update INBOX_CLEANUP_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update INBOX_CLEANUP_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -247,7 +238,7 @@
</span><span class="cx"> alter table INBOX_CLEANUP_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table INBOX_CLEANUP_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index INBOX_CLEANUP_WORK_JO_799132bd on INBOX_CLEANUP_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -257,7 +248,7 @@
</span><span class="cx"> -- CLEANUP_ONE_INBOX_WORK --
</span><span class="cx"> alter table CLEANUP_ONE_INBOX_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update CLEANUP_ONE_INBOX_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update CLEANUP_ONE_INBOX_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -266,7 +257,7 @@
</span><span class="cx"> alter table CLEANUP_ONE_INBOX_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table CLEANUP_ONE_INBOX_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index CLEANUP_ONE_INBOX_WOR_375dac36 on CLEANUP_ONE_INBOX_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -276,7 +267,7 @@
</span><span class="cx"> -- SCHEDULE_REFRESH_WORK --
</span><span class="cx"> alter table SCHEDULE_REFRESH_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update SCHEDULE_REFRESH_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update SCHEDULE_REFRESH_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -285,7 +276,7 @@
</span><span class="cx"> alter table SCHEDULE_REFRESH_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table SCHEDULE_REFRESH_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index SCHEDULE_REFRESH_WORK_3ffa2718 on SCHEDULE_REFRESH_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -295,7 +286,7 @@
</span><span class="cx"> -- SCHEDULE_AUTO_REPLY_WORK --
</span><span class="cx"> alter table SCHEDULE_AUTO_REPLY_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update SCHEDULE_AUTO_REPLY_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update SCHEDULE_AUTO_REPLY_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -304,7 +295,7 @@
</span><span class="cx"> alter table SCHEDULE_AUTO_REPLY_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table SCHEDULE_AUTO_REPLY_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index SCHEDULE_AUTO_REPLY_W_4d7bb5a8 on SCHEDULE_AUTO_REPLY_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -314,7 +305,7 @@
</span><span class="cx"> -- SCHEDULE_ORGANIZER_WORK --
</span><span class="cx"> alter table SCHEDULE_ORGANIZER_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update SCHEDULE_ORGANIZER_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update SCHEDULE_ORGANIZER_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -323,7 +314,7 @@
</span><span class="cx"> alter table SCHEDULE_ORGANIZER_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table SCHEDULE_ORGANIZER_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index SCHEDULE_ORGANIZER_WO_1e9f246d on SCHEDULE_ORGANIZER_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -333,7 +324,7 @@
</span><span class="cx"> -- SCHEDULE_REPLY_WORK --
</span><span class="cx"> alter table SCHEDULE_REPLY_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update SCHEDULE_REPLY_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update SCHEDULE_REPLY_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -342,7 +333,7 @@
</span><span class="cx"> alter table SCHEDULE_REPLY_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table SCHEDULE_REPLY_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index SCHEDULE_REPLY_WORK_J_5913b4a4 on SCHEDULE_REPLY_WORK (
</span><span class="cx">     JOB_ID
</span><span class="lines">@@ -352,7 +343,7 @@
</span><span class="cx"> -- SCHEDULE_REPLY_CANCEL_WORK --
</span><span class="cx"> alter table SCHEDULE_REPLY_CANCEL_WORK
</span><span class="cx">     add (&quot;JOB_ID&quot; integer default 0 not null);
</span><del>-update SCHEDULE_REPLY_CANCEL_WORK set JOB_ID = JOB_SEQ.nextval
</del><ins>+update SCHEDULE_REPLY_CANCEL_WORK set JOB_ID = JOB_SEQ.nextval;
</ins><span class="cx"> 
</span><span class="cx"> insert into JOB
</span><span class="cx">   (JOB_ID, WORK_TYPE, NOT_BEFORE)
</span><span class="lines">@@ -361,7 +352,7 @@
</span><span class="cx"> alter table SCHEDULE_REPLY_CANCEL_WORK
</span><span class="cx">     drop column NOT_BEFORE;
</span><span class="cx"> alter table SCHEDULE_REPLY_CANCEL_WORK
</span><del>-    add constraint foreign key (JOB_ID) references JOB;
</del><ins>+    modify (&quot;JOB_ID&quot; integer default null references JOB);
</ins><span class="cx"> 
</span><span class="cx"> create index SCHEDULE_REPLY_CANCEL_94a0c766 on SCHEDULE_REPLY_CANCEL_WORK (
</span><span class="cx">     JOB_ID
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_41_to_42sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -23,11 +23,13 @@
</span><span class="cx"> -----------------
</span><span class="cx"> 
</span><span class="cx"> alter table JOB
</span><del>-  modify (&quot;NOT_BEFORE&quot; timestamp not null)
</del><ins>+  modify (&quot;NOT_BEFORE&quot; timestamp not null);
+
+alter table JOB
</ins><span class="cx">   add (&quot;FAILED&quot; integer default 0);
</span><span class="cx"> 
</span><span class="cx"> alter table JOB
</span><del>-  rename column NOT_AFTER to ASSIGNED;
</del><ins>+  rename column &quot;NOT_AFTER&quot; to &quot;ASSIGNED&quot;;
</ins><span class="cx"> 
</span><span class="cx"> -- update the version
</span><span class="cx"> update CALENDARSERVER set VALUE = '42' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_43_to_44sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -18,12 +18,6 @@
</span><span class="cx"> -- Upgrade database schema from VERSION 43 to 44 --
</span><span class="cx"> ---------------------------------------------------
</span><span class="cx"> 
</span><del>------------------
--- Job Changes --
------------------
-
-drop function next_job;
-
</del><span class="cx"> -- The scheduling work schema has changed a lot - to avoid a complex migration process this
</span><span class="cx"> -- script just drops all the existing tables and adds back the new set
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_45_to_46sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -24,20 +24,22 @@
</span><span class="cx"> drop table GROUP_ATTENDEE_RECONCILE_WORK;
</span><span class="cx"> 
</span><span class="cx"> create table GROUP_ATTENDEE_RECONCILE_WORK (
</span><del>-  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
-  JOB_ID                        integer not null references JOB,
-  RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
-  GROUP_ID                      integer not null references GROUPS on delete cascade
</del><ins>+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade
</ins><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on GROUP_ATTENDEE_RECONCILE_WORK(
-        JOB_ID
</del><ins>+create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
+    JOB_ID
</ins><span class="cx"> );
</span><del>-create index GROUP_ATTENDEE_RECONCILE_WORK_RESOURCE_ID on GROUP_ATTENDEE_RECONCILE_WORK(
-        RESOURCE_ID
</del><ins>+
+create index GROUP_ATTENDEE_RECONC_b894ee7a on GROUP_ATTENDEE_RECONCILE_WORK (
+    RESOURCE_ID
</ins><span class="cx"> );
</span><del>-create index GROUP_ATTENDEE_RECONCILE_WORK_GROUP_ID on GROUP_ATTENDEE_RECONCILE_WORK(
-        GROUP_ID
</del><ins>+
+create index GROUP_ATTENDEE_RECONC_5eabc549 on GROUP_ATTENDEE_RECONCILE_WORK (
+    GROUP_ID
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx">   
</span><span class="lines">@@ -49,34 +51,35 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> create table GROUP_SHAREE_RECONCILE_WORK (
</span><del>-  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
-  JOB_ID                        integer not null references JOB,
-  CALENDAR_ID                   integer        not null references CALENDAR on delete cascade,
-  GROUP_ID                      integer not null references GROUPS on delete cascade
</del><ins>+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;CALENDAR_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade
</ins><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on GROUP_SHAREE_RECONCILE_WORK(
-        JOB_ID
</del><ins>+create index GROUP_SHAREE_RECONCIL_9aad0858 on GROUP_SHAREE_RECONCILE_WORK (
+    JOB_ID
</ins><span class="cx"> );
</span><del>-create index GROUP_SHAREE_RECONCILE_WORK_CALENDAR_ID on GROUP_SHAREE_RECONCILE_WORK(
-        CALENDAR_ID
</del><ins>+
+create index GROUP_SHAREE_RECONCIL_4dc60f78 on GROUP_SHAREE_RECONCILE_WORK (
+    CALENDAR_ID
</ins><span class="cx"> );
</span><del>-create index GROUP_SHAREE_RECONCILE_WORK_GROUP_ID on GROUP_SHAREE_RECONCILE_WORK(
-        GROUP_ID
</del><ins>+
+create index GROUP_SHAREE_RECONCIL_1d14c921 on GROUP_SHAREE_RECONCILE_WORK (
+    GROUP_ID
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> create table GROUP_SHAREE (
</span><del>-  GROUP_ID                      integer not null references GROUPS on delete cascade,
-  CALENDAR_ID                                      integer not null references CALENDAR on delete cascade,
-  GROUP_BIND_MODE               integer not null, -- enum CALENDAR_BIND_MODE
-  MEMBERSHIP_HASH               varchar(255) not null,
-  
-  primary key (GROUP_ID, CALENDAR_ID) -- implicit index
</del><ins>+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
+    &quot;CALENDAR_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;GROUP_BIND_MODE&quot; integer not null,
+    &quot;MEMBERSHIP_HASH&quot; nvarchar2(255), 
+    primary key (&quot;GROUP_ID&quot;, &quot;CALENDAR_ID&quot;)
</ins><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUP_SHAREE_CALENDAR_ID on GROUP_SHAREE(
-        CALENDAR_ID
</del><ins>+create index GROUP_SHAREE_CALENDAR_28a88850 on GROUP_SHAREE (
+    CALENDAR_ID
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_48_to_49sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_48_to_49.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_48_to_49.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_48_to_49.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -47,11 +47,11 @@
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_CHECK_198388a5 on PRINCIPAL_PURGE_CHECK_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create index PRINCIPAL_PURGE_WORK__db35cfdc on PRINCIPAL_PURGE_WORK (
</span><del>-    UID
</del><ins>+    &quot;UID&quot;
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_49_to_50sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_49_to_50.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_49_to_50.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_49_to_50.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx">         execute immediate 'alter table SCHEDULE_REPLY_WORK drop constraint '|| i.constraint_name;
</span><span class="cx">     end loop;
</span><span class="cx"> end;
</span><del>-alter table SCHEDULE_REPLY_WORK modify (&quot;RESOURCE_ID&quot; null);
</del><span class="cx"> 
</span><span class="cx"> -- Copy over items from existing table about to be dropped
</span><span class="cx"> insert into SCHEDULE_REPLY_WORK
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_4_to_5sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_4_to_5.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_4_to_5.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_4_to_5.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -18,41 +18,6 @@
</span><span class="cx"> -- Upgrade database schema from VERSION 4 to 5 --
</span><span class="cx"> -------------------------------------------------
</span><span class="cx"> 
</span><del>--- We have changed the hashing schema for index names, so rename
--- all indexes first
-
--- Note that Oracle already suppressed some indexes because they were implicit or invalid
-
---implicit alter index IDX_0_CALENDAR_HOME_OWNER_UID rename to CALENDAR_HOME_OWNER_U_78016c63;
-alter index IDX_1_CALENDAR_HOME_METADATA_R rename to CALENDAR_HOME_METADAT_35a84eec;
-alter index IDX_2_INVITE_INVITE_UID rename to INVITE_INVITE_UID_9b0902ff;
---invalid alter index IDX_3_INVITE_RESOURCE_ID rename to INVITE_RESOURCE_ID_b36ddc23;
---invalid alter index IDX_4_INVITE_HOME_RESOURCE_ID rename to INVITE_HOME_RESOURCE__e9bdf77e;
---implicit alter index IDX_5_NOTIFICATION_HOME_OWNER_ rename to NOTIFICATION_HOME_OWN_401a6203;
-alter index IDX_6_NOTIFICATION_NOTIFICATIO rename to NOTIFICATION_NOTIFICA_f891f5f9;
-alter index IDX_7_NOTIFICATION_NOTIFICATIO rename to NOTIFICATION_NOTIFICA_62daf834;
-alter index IDX_8_CALENDAR_BIND_HOME_RESOU rename to CALENDAR_BIND_HOME_RE_0d980be6;
-alter index IDX_9_CALENDAR_BIND_RESOURCE_I rename to CALENDAR_BIND_RESOURC_e57964d4;
-alter index IDX_10_CALENDAR_OBJECT_CALENDA rename to CALENDAR_OBJECT_CALEN_06694fd0;
-alter index IDX_11_CALENDAR_OBJECT_CALENDA rename to CALENDAR_OBJECT_CALEN_a9a453a9;
-alter index IDX_12_CALENDAR_OBJECT_CALENDA rename to CALENDAR_OBJECT_CALEN_96e83b73;
-alter index IDX_13_CALENDAR_OBJECT_ORGANIZ rename to CALENDAR_OBJECT_ORGAN_7ce24750;
-alter index IDX_14_CALENDAR_OBJECT_DROPBOX rename to CALENDAR_OBJECT_DROPB_de041d80;
-alter index IDX_15_TIME_RANGE_CALENDAR_RES rename to TIME_RANGE_CALENDAR_R_beb6e7eb;
-alter index IDX_16_TIME_RANGE_CALENDAR_OBJ rename to TIME_RANGE_CALENDAR_O_acf37bd1;
-alter index IDX_17_TRANSPARENCY_TIME_RANGE rename to TRANSPARENCY_TIME_RAN_5f34467f;
-alter index IDX_18_ATTACHMENT_DROPBOX_ID rename to ATTACHMENT_DROPBOX_ID_5073cf23;
---implicit alter index IDX_19_ADDRESSBOOK_HOME_OWNER_ rename to ADDRESSBOOK_HOME_OWNE_44f7f53b;
-alter index IDX_20_ADDRESSBOOK_HOME_METADA rename to ADDRESSBOOK_HOME_META_cfe06701;
-alter index IDX_21_ADDRESSBOOK_BIND_HOME_R rename to ADDRESSBOOK_BIND_HOME_6a6dc8ce;
-alter index IDX_22_ADDRESSBOOK_BIND_RESOUR rename to ADDRESSBOOK_BIND_RESO_205aa75c;
-alter index IDX_23_ADDRESSBOOK_OBJECT_ADDR rename to ADDRESSBOOK_OBJECT_AD_1540450d;
-alter index IDX_24_CALENDAR_OBJECT_REVISIO rename to CALENDAR_OBJECT_REVIS_42be4d9e;
-alter index IDX_25_CALENDAR_OBJECT_REVISIO rename to CALENDAR_OBJECT_REVIS_3e41b7f0;
-alter index IDX_26_ADDRESSBOOK_OBJECT_REVI rename to ADDRESSBOOK_OBJECT_RE_5965a9e2;
-alter index IDX_27_ADDRESSBOOK_OBJECT_REVI rename to ADDRESSBOOK_OBJECT_RE_2ab44f33;
-alter index IDX_28_NOTIFICATION_OBJECT_REV rename to NOTIFICATION_OBJECT_R_47002cd8;
-
</del><span class="cx"> -- Changes related to primary key and index optimizations
</span><span class="cx"> 
</span><span class="cx"> --implicit drop index CALENDAR_HOME_OWNER_U_78016c63;
</span><span class="lines">@@ -76,15 +41,14 @@
</span><span class="cx"> drop index CALENDAR_OBJECT_CALEN_06694fd0;
</span><span class="cx"> 
</span><span class="cx"> drop index ATTACHMENT_DROPBOX_ID_5073cf23;
</span><del>--- This constraint was not properly translated in original v4 schema
---alter table ATTACHMENT 
--- drop unique(DROPBOX_ID, PATH);
</del><ins>+
+alter table ATTACHMENT 
+ drop unique(DROPBOX_ID, PATH);
</ins><span class="cx"> alter table ATTACHMENT
</span><span class="cx">  add primary key(DROPBOX_ID, PATH);
</span><del>-create index ATTACHMENT_CALENDAR_H_0078845c on
-  ATTACHMENT(CALENDAR_HOME_RESOURCE_ID);
</del><span class="cx"> 
</span><del>---implicit drop index ADDRESSBOOK_HOME_OWNE_44f7f53b;
</del><ins>+ create index ATTACHMENT_CALENDAR_H_0078845c on
+  ATTACHMENT(CALENDAR_HOME_RESOURCE_ID);
</ins><span class="cx">   
</span><span class="cx"> drop index ADDRESSBOOK_HOME_META_cfe06701;
</span><span class="cx"> alter table ADDRESSBOOK_HOME_METADATA
</span><span class="lines">@@ -105,45 +69,20 @@
</span><span class="cx"> alter table CALENDARSERVER
</span><span class="cx">  add primary key(NAME);
</span><span class="cx"> 
</span><del>--- Changes to restore multi-column primary key and uniques lost in translation of v4

-alter table NOTIFICATION
- add unique(NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID);

-alter table CALENDAR_BIND
- add primary key(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID);
-alter table CALENDAR_BIND
- add unique(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_NAME);

-alter table CALENDAR_OBJECT
- add unique(CALENDAR_RESOURCE_ID, RESOURCE_NAME);

---alter table ATTACHMENT
--- add primary key(DROPBOX_ID, PATH);

-alter table RESOURCE_PROPERTY
- add primary key(RESOURCE_ID, NAME, VIEWER_UID);

-alter table ADDRESSBOOK_BIND
- add primary key(ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_ID);
-alter table ADDRESSBOOK_BIND
- add unique(ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_NAME);

-alter table ADDRESSBOOK_OBJECT
- add unique(ADDRESSBOOK_RESOURCE_ID, RESOURCE_NAME);
-alter table ADDRESSBOOK_OBJECT
- add unique(ADDRESSBOOK_RESOURCE_ID, VCARD_UID);

-create index CALENDAR_OBJECT_REVIS_2643d556
-  on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, RESOURCE_NAME);

-create index ADDRESSBOOK_OBJECT_RE_9a848f39
-  on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_RESOURCE_ID, RESOURCE_NAME);

-alter table NOTIFICATION_OBJECT_REVISIONS
- add unique(NOTIFICATION_HOME_RESOURCE_ID, RESOURCE_NAME);

</del><ins>+alter table CALENDAR_OBJECT_REVISIONS 
+ drop unique(CALENDAR_RESOURCE_ID, RESOURCE_NAME);
+create index CALENDAR_OBJECT_REVIS_2643d556 on CALENDAR_OBJECT_REVISIONS (
+    CALENDAR_RESOURCE_ID,
+    RESOURCE_NAME
+);
</ins><span class="cx"> 
</span><ins>+alter table ADDRESSBOOK_OBJECT_REVISIONS 
+ drop unique(ADDRESSBOOK_RESOURCE_ID, RESOURCE_NAME);
+create index ADDRESSBOOK_OBJECT_RE_9a848f39 on ADDRESSBOOK_OBJECT_REVISIONS (
+    ADDRESSBOOK_RESOURCE_ID,
+    RESOURCE_NAME
+);
+
</ins><span class="cx"> -- Now update the version
</span><span class="cx"> update CALENDARSERVER set VALUE = '5' where NAME = 'VERSION';
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_51_to_52sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -40,15 +40,18 @@
</span><span class="cx"> 
</span><span class="cx"> -- Change columns
</span><span class="cx"> alter table CALENDAR_BIND
</span><del>-        drop column EXTERNAL_ID
</del><ins>+        drop column EXTERNAL_ID;
+alter table CALENDAR_BIND
</ins><span class="cx">         add (&quot;BIND_UID&quot; nvarchar2(36) default null);
</span><span class="cx"> 
</span><span class="cx"> alter table SHARED_ADDRESSBOOK_BIND
</span><del>-        drop column EXTERNAL_ID
</del><ins>+        drop column EXTERNAL_ID;
+alter table SHARED_ADDRESSBOOK_BIND
</ins><span class="cx">         add (&quot;BIND_UID&quot; nvarchar2(36) default null);
</span><span class="cx"> 
</span><span class="cx"> alter table SHARED_GROUP_BIND
</span><del>-        drop column EXTERNAL_ID
</del><ins>+        drop column EXTERNAL_ID;
+alter table SHARED_GROUP_BIND
</ins><span class="cx">         add (&quot;BIND_UID&quot; nvarchar2(36) default null);
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_52_to_53sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_52_to_53.sql (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_52_to_53.sql        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_52_to_53.sql        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx"> 
</span><span class="cx"> -- New columns
</span><span class="cx"> alter table ADDRESSBOOK_OBJECT
</span><del>-  add (&quot;TRASHED&quot; timestamp default null),
</del><ins>+  add (&quot;TRASHED&quot; timestamp default null)
</ins><span class="cx">   add (&quot;IS_IN_TRASH&quot; integer default 0 not null);
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretesttest_oracle_sqlpy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/common/datastore/test/test_oracle_sql.py (0 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/test_oracle_sql.py                                (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_oracle_sql.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+##
+# Copyright (c) 2012-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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.
+##
+
+&quot;&quot;&quot;
+Tests for L{txdav.common.datastore.sql}.
+&quot;&quot;&quot;
+
+from twext.enterprise.dal.syntax import Select, Insert, Delete
+from twisted.internet.defer import inlineCallbacks
+from twisted.trial.unittest import TestCase
+from txdav.common.datastore.sql_tables import schema
+from txdav.common.datastore.test.util import CommonCommonTests
+
+
+class OracleSpecificSQLStoreTests(CommonCommonTests, TestCase):
+    &quot;&quot;&quot;
+    Tests for shared functionality in L{txdav.common.datastore.sql}.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def setUp(self):
+        &quot;&quot;&quot;
+        Set up two stores to migrate between.
+        &quot;&quot;&quot;
+        yield super(OracleSpecificSQLStoreTests, self).setUp()
+        yield self.buildStoreAndDirectory()
+
+
+    @inlineCallbacks
+    def test_logging(self):
+        &quot;&quot;&quot;
+        txn.execSQL works with all logging options on.
+        &quot;&quot;&quot;
+
+        # Patch config to turn on logging then rebuild the store
+        self.patch(self.store, &quot;logLabels&quot;, True)
+        self.patch(self.store, &quot;logStats&quot;, True)
+        self.patch(self.store, &quot;logSQL&quot;, True)
+
+        txn = self.transactionUnderTest()
+        cs = schema.CALENDARSERVER
+        version = (yield Select(
+            [cs.VALUE],
+            From=cs,
+            Where=cs.NAME == &quot;VERSION&quot;,
+        ).on(txn))
+        self.assertNotEqual(version, None)
+        self.assertEqual(len(version), 1)
+        self.assertEqual(len(version[0]), 1)
+
+
+    @inlineCallbacks
+    def test_delete_returning(self):
+        &quot;&quot;&quot;
+        txn.execSQL works with all logging options on.
+        &quot;&quot;&quot;
+
+        txn = self.transactionUnderTest()
+        cs = schema.CALENDARSERVER
+        yield Insert(
+            {cs.NAME: &quot;TEST&quot;, cs.VALUE: &quot;Value&quot;},
+        ).on(txn)
+        yield self.commit()
+
+        txn = self.transactionUnderTest()
+        value = yield Delete(
+            From=cs,
+            Where=(cs.NAME == &quot;TEST&quot;),
+            Return=cs.VALUE,
+        ).on(txn)
+        self.assertEqual(list(value), [[&quot;Value&quot;]])
+
+        txn = self.transactionUnderTest()
+        value = yield Delete(
+            From=cs,
+            Where=(cs.NAME == &quot;TEST&quot;),
+            Return=cs.VALUE,
+        ).on(txn)
+        self.assertEqual(list(value), [])
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretesttest_sql_dumppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -14,37 +14,51 @@
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><span class="cx"> 
</span><del>-from txdav.common.datastore.sql_dump import dumpSchema
-from twext.enterprise.dal.parseschema import schemaFromString
</del><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><ins>+from twext.enterprise.dal.parseschema import schemaFromString
+from twext.enterprise.ienterprise import POSTGRES_DIALECT
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><del>-from txdav.common.datastore.test.util import theStoreBuilder, \
-    StubNotifierFactory
</del><ins>+from txdav.base.datastore.suboracle import cleanDatabase
+from txdav.common.datastore.sql_dump import dumpSchema
+from txdav.common.datastore.test.util import StubNotifierFactory, SQLStoreBuilder,\
+    DB_TYPE, theStoreBuilder
</ins><span class="cx"> 
</span><span class="cx"> class SQLDump(TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Tests for L{sql_dump}.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><ins>+    def __init__(self, methodName='runTest'):
+        super(SQLDump, self).__init__(methodName)
+        if DB_TYPE[0] == POSTGRES_DIALECT:
+            self.testStoreBuilder = theStoreBuilder
+        else:
+            self.testStoreBuilder = SQLStoreBuilder(dsnUser=&quot;test_dbUpgrades&quot;, noCleanup=True)
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def setUp(self):
</span><span class="cx">         TestCase.setUp(self)
</span><span class="cx"> 
</span><del>-        self.store = yield theStoreBuilder.buildStore(
</del><ins>+        self.store = yield self.testStoreBuilder.buildStore(
</ins><span class="cx">             self, {&quot;push&quot;: StubNotifierFactory()}, enableJobProcessing=False
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def cleanUp(self):
</span><del>-        startTxn = self.store.newTransaction(&quot;test_sql_dump&quot;)
-        yield startTxn.execSQL(&quot;set search_path to public;&quot;)
-        yield startTxn.execSQL(&quot;drop schema test_sql_dump cascade;&quot;)
</del><ins>+        startTxn = self.store.newTransaction(&quot;test_dbUpgrades&quot;)
+        if startTxn.dialect == POSTGRES_DIALECT:
+            yield startTxn.execSQL(&quot;set search_path to public&quot;)
+            yield startTxn.execSQL(&quot;drop schema test_dbUpgrades cascade&quot;)
+        else:
+            yield cleanDatabase(startTxn)
+
</ins><span class="cx">         yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -54,10 +68,11 @@
</span><span class="cx">         Use the postgres schema mechanism to do tests under a separate &quot;namespace&quot;
</span><span class="cx">         in postgres that we can quickly wipe clean afterwards.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        startTxn = self.store.newTransaction(&quot;test_sql_dump&quot;)
-        yield startTxn.execSQL(&quot;create schema test_sql_dump;&quot;)
-        yield startTxn.execSQL(&quot;set search_path to test_sql_dump;&quot;)
-        yield startTxn.execSQL(schema)
</del><ins>+        startTxn = self.store.newTransaction(&quot;test_dbUpgrades&quot;)
+        if startTxn.dialect == POSTGRES_DIALECT:
+            yield startTxn.execSQL(&quot;create schema test_dbUpgrades&quot;)
+            yield startTxn.execSQL(&quot;set search_path to test_dbUpgrades&quot;)
+        yield startTxn.execSQLBlock(schema)
</ins><span class="cx">         yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         self.addCleanup(self.cleanUp)
</span><span class="lines">@@ -70,7 +85,7 @@
</span><span class="cx">         yield self._loadSchema(schema)
</span><span class="cx"> 
</span><span class="cx">         txn = self.store.newTransaction(&quot;loadData&quot;)
</span><del>-        dumped = yield dumpSchema(txn, &quot;test&quot;, schemaname=&quot;test_sql_dump&quot;)
</del><ins>+        dumped = yield dumpSchema(txn, &quot;test&quot;, schemaname=&quot;test_dbUpgrades&quot;)
</ins><span class="cx">         yield txn.commit()
</span><span class="cx"> 
</span><span class="cx">         parsed = schemaFromString(schema)
</span><span class="lines">@@ -218,3 +233,130 @@
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         yield self._schemaCheck(schema, schema_bad)
</span><ins>+
+
+    @inlineCallbacks
+    def test_timestamp_table(self):
+
+        schema = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key,
+    ID2 timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+&quot;&quot;&quot; if DB_TYPE[0] == POSTGRES_DIALECT else &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key,
+    ID2 timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+&quot;&quot;&quot;
+
+        schema_bad = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key default 0,
+    ID2 timestamp
+);
+&quot;&quot;&quot;
+
+        yield self._schemaCheck(schema, schema_bad)
+
+
+    @inlineCallbacks
+    def test_references_table(self):
+
+        schema = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key,
+    ID2 text default null
+);
+CREATE TABLE BAR (
+    ID1 integer references FOO on delete cascade,
+    ID2 integer
+);
+CREATE TABLE BAZ (
+    ID1 integer references FOO,
+    ID2 integer
+);
+&quot;&quot;&quot; if DB_TYPE[0] == POSTGRES_DIALECT else &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key,
+    ID2 nclob default null
+);
+CREATE TABLE BAR (
+    ID1 integer references FOO on delete cascade,
+    ID2 integer
+);
+CREATE TABLE BAZ (
+    ID1 integer references FOO,
+    ID2 integer
+);
+&quot;&quot;&quot;
+        schema_bad = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer primary key default 0,
+    ID2 timestamp
+);
+CREATE TABLE BAR (
+    ID1 integer references FOO,
+    ID2 integer
+);
+CREATE TABLE BAZ (
+    ID1 integer references FOO on delete cascade,
+    ID2 integer
+);
+&quot;&quot;&quot;
+
+        yield self._schemaCheck(schema, schema_bad)
+
+
+    @inlineCallbacks
+    def test_index_table(self):
+
+        schema = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer not null,
+    ID2 integer not null,
+
+    primary key (ID1)
+);
+
+create index FOOINDEX on FOO (ID1, ID2);
+&quot;&quot;&quot;
+
+        schema_bad = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer,
+    ID2 integer,
+
+    primary key (ID1)
+);
+create index FOOINDEX on FOO (ID2, ID1);
+&quot;&quot;&quot;
+
+        yield self._schemaCheck(schema, schema_bad)
+
+
+    @inlineCallbacks
+    def test_unique_index_table(self):
+
+        schema = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer not null,
+    ID2 integer not null,
+
+    primary key (ID1)
+);
+
+create unique index FOOINDEX on FOO(ID1, ID2);
+&quot;&quot;&quot;
+
+        schema_bad = &quot;&quot;&quot;
+CREATE TABLE FOO (
+    ID1 integer,
+    ID2 integer,
+
+    primary key (ID1)
+);
+create index FOOINDEX on FOO(ID1, ID2);
+&quot;&quot;&quot;
+
+        yield self._schemaCheck(schema, schema_bad)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/util.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -35,7 +35,8 @@
</span><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> from twext.python.filepath import CachingFilePath as FilePath
</span><span class="cx"> from twext.enterprise.adbapi2 import ConnectionPool
</span><del>-from twext.enterprise.ienterprise import AlreadyFinishedError
</del><ins>+from twext.enterprise.ienterprise import AlreadyFinishedError, POSTGRES_DIALECT, \
+    ORACLE_DIALECT
</ins><span class="cx"> from twext.enterprise.jobqueue import PeerConnectionPool, JobItem
</span><span class="cx"> from twext.who.directory import DirectoryRecord
</span><span class="cx"> 
</span><span class="lines">@@ -54,6 +55,7 @@
</span><span class="cx"> 
</span><span class="cx"> from txdav.base.datastore.dbapiclient import DiagnosticConnectionWrapper
</span><span class="cx"> from txdav.base.datastore.subpostgres import PostgresService
</span><ins>+from txdav.base.datastore.suboracle import OracleService
</ins><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><span class="cx"> from txdav.caldav.icalendarstore import ComponentUpdateState
</span><span class="cx"> from txdav.common.datastore.sql import CommonDataStore, current_sql_schema
</span><span class="lines">@@ -70,6 +72,8 @@
</span><span class="cx"> import gc
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+DB_TYPE = (POSTGRES_DIALECT, &quot;pyformat&quot;, &quot;current.sql&quot;,)
+#DB_TYPE = (ORACLE_DIALECT, &quot;numeric&quot;, &quot;current-oracle-dialect.sql&quot;,)
</ins><span class="cx"> 
</span><span class="cx"> log = Logger()
</span><span class="cx"> 
</span><span class="lines">@@ -105,7 +109,7 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Test-fixture-builder which can construct a PostgresStore.
</span><span class="cx">     &quot;&quot;&quot;
</span><del>-    def __init__(self, count=0):
</del><ins>+    def __init__(self, count=0, **options):
</ins><span class="cx">         self.sharedService = None
</span><span class="cx">         self.currentTestID = None
</span><span class="cx">         self.ampPort = config.WorkQueue.ampPort + count
</span><span class="lines">@@ -114,26 +118,35 @@
</span><span class="cx">             os.getpid(), count
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+        self.options = options
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     def createService(self, serviceFactory):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Create a L{PostgresService} to use for building a store.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         dbRoot = FilePath(self.sharedDBPath)
</span><del>-        return PostgresService(
-            dbRoot, serviceFactory, current_sql_schema, resetSchema=True,
-            databaseName=&quot;caldav&quot;,
-            options=[
-                &quot;-c log_lock_waits=TRUE&quot;,
-                &quot;-c log_statement=all&quot;,
-                &quot;-c log_line_prefix='%p.%x '&quot;,
-                &quot;-c fsync=FALSE&quot;,
-                &quot;-c synchronous_commit=off&quot;,
-                &quot;-c full_page_writes=FALSE&quot;,
-                &quot;-c client-min-messages=warning&quot;,
-            ],
-            testMode=True
-        )
</del><ins>+        if DB_TYPE[0] == POSTGRES_DIALECT:
+            return PostgresService(
+                dbRoot, serviceFactory, current_sql_schema, resetSchema=True,
+                databaseName=&quot;caldav&quot;,
+                options=[
+                    &quot;-c log_lock_waits=TRUE&quot;,
+                    &quot;-c log_statement=all&quot;,
+                    &quot;-c log_line_prefix='%p.%x '&quot;,
+                    &quot;-c fsync=FALSE&quot;,
+                    &quot;-c synchronous_commit=off&quot;,
+                    &quot;-c full_page_writes=FALSE&quot;,
+                    &quot;-c client-min-messages=warning&quot;,
+                ],
+                testMode=True
+            )
+        elif DB_TYPE[0] == ORACLE_DIALECT:
+            return OracleService(
+                dbRoot, serviceFactory,
+                testMode=True,
+                dsnUser=self.options.get(&quot;dsnUser&quot;),
+            )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def childStore(self):
</span><span class="lines">@@ -146,7 +159,12 @@
</span><span class="cx">         attachmentRoot = (FilePath(self.sharedDBPath).child(&quot;attachments&quot;))
</span><span class="cx">         stubsvc = self.createService(lambda cf: Service())
</span><span class="cx"> 
</span><del>-        cp = ConnectionPool(stubsvc.produceConnection, maxConnections=1)
</del><ins>+        cp = ConnectionPool(
+            stubsvc.produceConnection,
+            maxConnections=1,
+            dialect=DB_TYPE[0],
+            paramstyle=DB_TYPE[1],
+        )
</ins><span class="cx">         # Attach the service to the running reactor.
</span><span class="cx">         cp.startService()
</span><span class="cx">         reactor.addSystemEventTrigger(&quot;before&quot;, &quot;shutdown&quot;, cp.stopService)
</span><span class="lines">@@ -231,7 +249,10 @@
</span><span class="cx"> 
</span><span class="cx">         currentTestID = testCase.id()
</span><span class="cx">         cp = ConnectionPool(
</span><del>-            self.sharedService.produceConnection, maxConnections=4
</del><ins>+            self.sharedService.produceConnection,
+            maxConnections=4,
+            dialect=DB_TYPE[0],
+            paramstyle=DB_TYPE[1],
</ins><span class="cx">         )
</span><span class="cx">         quota = deriveQuota(testCase)
</span><span class="cx">         store = CommonDataStore(
</span><span class="lines">@@ -250,12 +271,14 @@
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def stopIt():
</span><del>-            txn = store.newTransaction()
-            jobs = yield JobItem.all(txn)
-            yield txn.commit()
</del><span class="cx"> 
</span><span class="cx">             if enableJobProcessing:
</span><ins>+                txn = store.newTransaction()
+                jobs = yield JobItem.all(txn)
+                yield txn.commit()
</ins><span class="cx">                 yield pool.stopService()
</span><ins>+            else:
+                jobs = ()
</ins><span class="cx"> 
</span><span class="cx">             # active transactions should have been shut down.
</span><span class="cx">             wasBusy = len(cp._busy)
</span><span class="lines">@@ -293,6 +316,9 @@
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def cleanStore(self, testCase, storeToClean):
</span><span class="cx"> 
</span><ins>+        if &quot;noCleanup&quot; in self.options:
+            returnValue(None)
+
</ins><span class="cx">         cleanupTxn = storeToClean.sqlTxnFactory(
</span><span class="cx">             &quot;%s schema-cleanup&quot; % (testCase.id(),)
</span><span class="cx">         )
</span><span class="lines">@@ -318,8 +344,13 @@
</span><span class="cx">         # Change the starting values of sequences to random values
</span><span class="cx">         for sequence in schema.model.sequences: #@UndefinedVariable
</span><span class="cx">             try:
</span><del>-                curval = (yield cleanupTxn.execSQL(&quot;select nextval('{}')&quot;.format(sequence.name), []))[0][0]
-                yield cleanupTxn.execSQL(&quot;select setval('{}', {})&quot;.format(sequence.name, curval + randint(1, 10000)), [])
</del><ins>+                if cleanupTxn.dialect == POSTGRES_DIALECT:
+                    curval = (yield cleanupTxn.execSQL(&quot;select nextval('{}')&quot;.format(sequence.name), []))[0][0]
+                    yield cleanupTxn.execSQL(&quot;select setval('{}', {})&quot;.format(sequence.name, curval + randint(1, 10000)), [])
+                elif cleanupTxn.dialect == ORACLE_DIALECT:
+                    yield cleanupTxn.execSQL(&quot;alter sequence {} increment by {}&quot;.format(sequence.name, randint(1, 10000)), [])
+                    yield cleanupTxn.execSQL(&quot;select {}.nextval from dual&quot;.format(sequence.name), [])
+                    yield cleanupTxn.execSQL(&quot;alter sequence {} increment by {}&quot;.format(sequence.name, 1), [])
</ins><span class="cx">             except:
</span><span class="cx">                 log.failure(&quot;setval sequence '{}' failed&quot;, sequence=sequence.name)
</span><span class="cx">         yield cleanupTxn.execSQL(&quot;update CALENDARSERVER set VALUE = '1' where NAME = 'MIN-VALID-REVISION'&quot;, [])
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradesqltesttest_upgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py (14597 => 14598)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py        2015-03-16 03:01:36 UTC (rev 14597)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py        2015-03-16 03:04:19 UTC (rev 14598)
</span><span class="lines">@@ -23,8 +23,10 @@
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.python.modules import getModule
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><ins>+from txdav.base.datastore.suboracle import cleanDatabase
</ins><span class="cx"> from txdav.common.datastore.sql_dump import dumpSchema
</span><del>-from txdav.common.datastore.test.util import theStoreBuilder, StubNotifierFactory
</del><ins>+from txdav.common.datastore.test.util import StubNotifierFactory, SQLStoreBuilder, \
+    DB_TYPE, theStoreBuilder
</ins><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrade import (
</span><span class="cx">     UpgradeDatabaseSchemaStep, UpgradeDatabaseAddressBookDataStep, UpgradeDatabaseCalendarDataStep, NotAllowedToUpgrade)
</span><span class="cx"> import re
</span><span class="lines">@@ -34,6 +36,14 @@
</span><span class="cx">     Tests for L{UpgradeDatabaseSchemaStep}.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><ins>+    def __init__(self, methodName='runTest'):
+        super(SchemaUpgradeTests, self).__init__(methodName)
+        if DB_TYPE[0] == POSTGRES_DIALECT:
+            self.testStoreBuilder = theStoreBuilder
+        else:
+            self.testStoreBuilder = SQLStoreBuilder(dsnUser=&quot;test_dbUpgrades&quot;, noCleanup=True)
+
+
</ins><span class="cx">     @staticmethod
</span><span class="cx">     def _getRawSchemaVersion(fp, versionKey):
</span><span class="cx">         schema = fp.getContent()
</span><span class="lines">@@ -121,7 +131,7 @@
</span><span class="cx">             upgrader = UpgradeDatabaseSchemaStep(None)
</span><span class="cx">             files = upgrader.scanForUpgradeFiles(dialect)
</span><span class="cx"> 
</span><del>-            current_version = self._getSchemaVersion(upgrader.schemaLocation.child(&quot;current.sql&quot;), &quot;VERSION&quot;)
</del><ins>+            current_version = self._getSchemaVersion(upgrader.schemaLocation.child(DB_TYPE[2]), &quot;VERSION&quot;)
</ins><span class="cx"> 
</span><span class="cx">             for child in upgrader.schemaLocation.child(&quot;old&quot;).child(dialect).globChildren(&quot;*.sql&quot;):
</span><span class="cx">                 old_version = self._getSchemaVersion(child, &quot;VERSION&quot;)
</span><span class="lines">@@ -150,7 +160,7 @@
</span><span class="cx">         postgres.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        store = yield theStoreBuilder.buildStore(
</del><ins>+        store = yield self.testStoreBuilder.buildStore(
</ins><span class="cx">             self, {&quot;push&quot;: StubNotifierFactory()}, enableJobProcessing=False
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -161,15 +171,16 @@
</span><span class="cx">             in postgres that we can quickly wipe clean afterwards.
</span><span class="cx">             &quot;&quot;&quot;
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;create schema test_dbUpgrades;&quot;)
-            yield startTxn.execSQL(&quot;set search_path to test_dbUpgrades;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;create schema test_dbUpgrades&quot;)
+                yield startTxn.execSQL(&quot;set search_path to test_dbUpgrades&quot;)
</ins><span class="cx">             yield startTxn.execSQLBlock(path.getContent())
</span><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _loadVersion():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            new_version = yield startTxn.execSQL(&quot;select value from calendarserver where name = 'VERSION';&quot;)
</del><ins>+            new_version = yield startTxn.execSQL(&quot;select value from calendarserver where name = 'VERSION'&quot;)
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx">             returnValue(int(new_version[0][0]))
</span><span class="cx"> 
</span><span class="lines">@@ -183,21 +194,27 @@
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _unloadOldSchema():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;set search_path to public;&quot;)
-            yield startTxn.execSQL(&quot;drop schema test_dbUpgrades cascade;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;set search_path to public&quot;)
+                yield startTxn.execSQL(&quot;drop schema test_dbUpgrades cascade&quot;)
+            elif startTxn.dialect == ORACLE_DIALECT:
+                yield cleanDatabase(startTxn)
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _cleanupOldSchema():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;set search_path to public;&quot;)
-            yield startTxn.execSQL(&quot;drop schema if exists test_dbUpgrades cascade;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;set search_path to public&quot;)
+                yield startTxn.execSQL(&quot;drop schema if exists test_dbUpgrades cascade&quot;)
+            elif startTxn.dialect == ORACLE_DIALECT:
+                yield cleanDatabase(startTxn)
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         self.addCleanup(_cleanupOldSchema)
</span><span class="cx"> 
</span><span class="cx">         test_upgrader = UpgradeDatabaseSchemaStep(None)
</span><del>-        expected_version = self._getSchemaVersion(test_upgrader.schemaLocation.child(&quot;current.sql&quot;), &quot;VERSION&quot;)
</del><ins>+        expected_version = self._getSchemaVersion(test_upgrader.schemaLocation.child(DB_TYPE[2]), &quot;VERSION&quot;)
</ins><span class="cx"> 
</span><span class="cx">         # Upgrade allowed
</span><span class="cx">         upgrader = UpgradeDatabaseSchemaStep(store)
</span><span class="lines">@@ -207,7 +224,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Compare the upgraded schema with the expected current schema
</span><span class="cx">         new_schema = yield _loadSchemaFromDatabase()
</span><del>-        currentSchema = schemaFromPath(test_upgrader.schemaLocation.child(&quot;current.sql&quot;))
</del><ins>+        currentSchema = schemaFromPath(test_upgrader.schemaLocation.child(DB_TYPE[2]))
</ins><span class="cx">         mismatched = currentSchema.compare(new_schema)
</span><span class="cx">         # These are special case exceptions
</span><span class="cx">         for i in (
</span><span class="lines">@@ -256,7 +273,7 @@
</span><span class="cx">         store.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        store = yield theStoreBuilder.buildStore(
</del><ins>+        store = yield self.testStoreBuilder.buildStore(
</ins><span class="cx">             self, {&quot;push&quot;: StubNotifierFactory()}, enableJobProcessing=False
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -267,41 +284,48 @@
</span><span class="cx">             in postgres that we can quickly wipe clean afterwards.
</span><span class="cx">             &quot;&quot;&quot;
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;create schema test_dbUpgrades;&quot;)
-            yield startTxn.execSQL(&quot;set search_path to test_dbUpgrades;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;create schema test_dbUpgrades&quot;)
+                yield startTxn.execSQL(&quot;set search_path to test_dbUpgrades&quot;)
</ins><span class="cx">             yield startTxn.execSQLBlock(path.getContent())
</span><del>-            yield startTxn.execSQL(&quot;update CALENDARSERVER set VALUE = '%s' where NAME = '%s';&quot; % (oldVersion, versionKey,))
</del><ins>+            yield startTxn.execSQL(&quot;update CALENDARSERVER set VALUE = '%s' where NAME = '%s'&quot; % (oldVersion, versionKey,))
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _loadVersion():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            new_version = yield startTxn.execSQL(&quot;select value from calendarserver where name = '%s';&quot; % (versionKey,))
</del><ins>+            new_version = yield startTxn.execSQL(&quot;select value from calendarserver where name = '%s'&quot; % (versionKey,))
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx">             returnValue(int(new_version[0][0]))
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _unloadOldData():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;set search_path to public;&quot;)
-            yield startTxn.execSQL(&quot;drop schema test_dbUpgrades cascade;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;set search_path to public&quot;)
+                yield startTxn.execSQL(&quot;drop schema test_dbUpgrades cascade&quot;)
+            elif startTxn.dialect == ORACLE_DIALECT:
+                yield cleanDatabase(startTxn)
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def _cleanupOldData():
</span><span class="cx">             startTxn = store.newTransaction(&quot;test_dbUpgrades&quot;)
</span><del>-            yield startTxn.execSQL(&quot;set search_path to public;&quot;)
-            yield startTxn.execSQL(&quot;drop schema if exists test_dbUpgrades cascade;&quot;)
</del><ins>+            if startTxn.dialect == POSTGRES_DIALECT:
+                yield startTxn.execSQL(&quot;set search_path to public&quot;)
+                yield startTxn.execSQL(&quot;drop schema if exists test_dbUpgrades cascade&quot;)
+            elif startTxn.dialect == ORACLE_DIALECT:
+                yield cleanDatabase(startTxn)
</ins><span class="cx">             yield startTxn.commit()
</span><span class="cx"> 
</span><span class="cx">         self.addCleanup(_cleanupOldData)
</span><span class="cx"> 
</span><span class="cx">         test_upgrader = UpgradeDatabaseSchemaStep(None)
</span><del>-        expected_version = self._getSchemaVersion(test_upgrader.schemaLocation.child(&quot;current.sql&quot;), versionKey)
</del><ins>+        expected_version = self._getSchemaVersion(test_upgrader.schemaLocation.child(DB_TYPE[2]), versionKey)
</ins><span class="cx"> 
</span><span class="cx">         oldVersion = version
</span><span class="cx">         upgrader = upgraderClass(store)
</span><del>-        yield _loadOldData(test_upgrader.schemaLocation.child(&quot;current.sql&quot;), oldVersion)
</del><ins>+        yield _loadOldData(test_upgrader.schemaLocation.child(DB_TYPE[2]), oldVersion)
</ins><span class="cx">         yield upgrader.databaseUpgrade()
</span><span class="cx">         new_version = yield _loadVersion()
</span><span class="cx">         yield _unloadOldData()
</span><span class="lines">@@ -311,15 +335,17 @@
</span><span class="cx"> 
</span><span class="cx"> test_upgrader = UpgradeDatabaseSchemaStep(None)
</span><span class="cx"> 
</span><ins>+DIALECT = DB_TYPE[0]
+
</ins><span class="cx"> # Bind test methods for each schema version
</span><del>-for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(POSTGRES_DIALECT).globChildren(&quot;*.sql&quot;):
</del><ins>+for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(DIALECT).globChildren(&quot;*.sql&quot;):
</ins><span class="cx">     def f(self, lchild=child):
</span><span class="cx">         return self._dbSchemaUpgrades(lchild)
</span><span class="cx">     setattr(SchemaUpgradeTests, &quot;test_dbSchemaUpgrades_%s&quot; % (child.basename().split(&quot;.&quot;, 1)[0],), f)
</span><span class="cx"> 
</span><span class="cx"> # Bind test methods for each addressbook data version
</span><span class="cx"> versions = set()
</span><del>-for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(POSTGRES_DIALECT).globChildren(&quot;*.sql&quot;):
</del><ins>+for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(DIALECT).globChildren(&quot;*.sql&quot;):
</ins><span class="cx">     version = SchemaUpgradeTests._getRawSchemaVersion(child, &quot;ADDRESSBOOK-DATAVERSION&quot;)
</span><span class="cx">     versions.add(version if version else 1)
</span><span class="cx"> for version in sorted(versions):
</span><span class="lines">@@ -329,7 +355,7 @@
</span><span class="cx"> 
</span><span class="cx"> # Bind test methods for each calendar data version
</span><span class="cx"> versions = set()
</span><del>-for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(POSTGRES_DIALECT).globChildren(&quot;*.sql&quot;):
</del><ins>+for child in test_upgrader.schemaLocation.child(&quot;old&quot;).child(DIALECT).globChildren(&quot;*.sql&quot;):
</ins><span class="cx">     version = SchemaUpgradeTests._getRawSchemaVersion(child, &quot;CALENDAR-DATAVERSION&quot;)
</span><span class="cx">     versions.add(version if version else 1)
</span><span class="cx"> for version in sorted(versions):
</span></span></pre>
</div>
</div>

</body>
</html>