<!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>[14419] CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore</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/14419">14419</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-02-16 16:08:14 -0800 (Mon, 16 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use DAL records for migration meta-data table access.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationhome_syncpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtesttest_home_syncpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_directorypy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_directory.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemacurrentsql">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_51_to_52sql">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_51_to_52sql">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_51_to_52.sql</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationmigration_metadatapy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/migration_metadata.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationhome_syncpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -14,17 +14,15 @@
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><span class="cx">
</span><del>-from collections import namedtuple
</del><span class="cx"> from functools import wraps
</span><span class="cx">
</span><del>-from twext.enterprise.dal.syntax import Select, Delete, Parameter, Insert, \
- Update
</del><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> from twisted.internet.defer import returnValue, inlineCallbacks
</span><span class="cx"> from twisted.python.failure import Failure
</span><span class="cx"> from txdav.caldav.icalendarstore import ComponentUpdateState
</span><ins>+from txdav.common.datastore.podding.migration.migration_metadata import CalendarMigrationRecord, \
+ CalendarObjectMigrationRecord, AttachmentMigrationRecord
</ins><span class="cx"> from txdav.caldav.datastore.sql import ManagedAttachment
</span><del>-from txdav.common.datastore.sql_tables import schema
</del><span class="cx"> from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
</span><span class="cx">
</span><span class="cx"> import uuid
</span><span class="lines">@@ -83,8 +81,6 @@
</span><span class="cx">
</span><span class="cx"> BATCH_SIZE = 50
</span><span class="cx">
</span><del>- CalendarSyncState = namedtuple("CalendarSyncState", ("localID", "lastSyncToken",))
-
</del><span class="cx"> def __init__(self, store, diruid):
</span><span class="cx"> """
</span><span class="cx"> @param store: the data store
</span><span class="lines">@@ -292,7 +288,7 @@
</span><span class="cx"> # Remote sync details
</span><span class="cx"> remote_sync_state = yield self.getCalendarSyncList()
</span><span class="cx">
</span><del>- # TODO: get local sync details from local DB
</del><ins>+ # Get local sync details from local DB
</ins><span class="cx"> local_sync_state = yield self.getSyncState()
</span><span class="cx">
</span><span class="cx"> # Remove local calendars no longer on the remote side
</span><span class="lines">@@ -319,7 +315,12 @@
</span><span class="cx"> for calendar in calendars:
</span><span class="cx"> if calendar.owned():
</span><span class="cx"> sync_token = yield calendar.syncToken()
</span><del>- results[calendar.id()] = self.CalendarSyncState(0, sync_token)
</del><ins>+ results[calendar.id()] = CalendarMigrationRecord.make(
+ calendarHomeResourceID=home.id(),
+ remoteResourceID=calendar.id(),
+ localResourceID=0,
+ lastSyncToken=sync_token,
+ )
</ins><span class="cx">
</span><span class="cx"> returnValue(results)
</span><span class="cx">
</span><span class="lines">@@ -330,59 +331,29 @@
</span><span class="cx"> """
</span><span class="cx"> Get local synchronization state for the home being migrated.
</span><span class="cx"> """
</span><del>- cm = schema.CALENDAR_MIGRATION
- rows = yield Select(
- columns=(cm.REMOTE_RESOURCE_ID, cm.CALENDAR_RESOURCE_ID, cm.LAST_SYNC_TOKEN,),
- From=cm,
- Where=(cm.CALENDAR_HOME_RESOURCE_ID == self.homeId)
- ).on(txn)
- returnValue(dict([(remote_id, self.CalendarSyncState(local_id, sync,)) for remote_id, local_id, sync in rows]))
</del><ins>+ records = yield CalendarMigrationRecord.querysimple(
+ txn, calendarHomeResourceID=self.homeId
+ )
+ returnValue(dict([(record.remoteResourceID, record) for record in records]))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inTransactionWrapper
</span><span class="cx"> @inlineCallbacks
</span><del>- def setSyncState(self, txn, details):
</del><ins>+ def updateSyncState(self, txn, stateRecord, newSyncToken):
</ins><span class="cx"> """
</span><del>- Get local synchronization state for the home being migrated.
</del><ins>+ Update or insert an L{CalendarMigrationRecord} with the new specified sync token.
</ins><span class="cx"> """
</span><del>- cm = schema.CALENDAR_MIGRATION
</del><ins>+ if stateRecord.isnew():
+ stateRecord.lastSyncToken = newSyncToken
+ yield stateRecord.insert(txn)
+ else:
+ # The existing stateRecord has a stale txn, but valid column values. We have
+ # to duplicate it before we can give it a different txn.
+ stateRecord = stateRecord.duplicate()
+ stateRecord.transaction = txn
+ yield stateRecord.update(lastSyncToken=newSyncToken)
</ins><span class="cx">
</span><del>- old_details = yield self.getSyncState(txn=txn)
</del><span class="cx">
</span><del>- # Remove missing keys
- missing = set(old_details.keys()) - set(details.keys())
- if missing:
- yield Delete(
- From=cm,
- Where=(cm.CALENDAR_HOME_RESOURCE_ID == self.homeId).And(
- cm.REMOTE_RESOURCE_ID.In(Parameter("missing", len(missing)))
- )
- ).on(txn, missing=missing)
-
- # Add new ones
- insert = set(details.keys()) - set(old_details.keys())
- for key in insert:
- yield Insert({
- cm.CALENDAR_HOME_RESOURCE_ID: self.homeId,
- cm.REMOTE_RESOURCE_ID: key,
- cm.CALENDAR_RESOURCE_ID: details[key].localID,
- cm.LAST_SYNC_TOKEN: details[key].lastSyncToken,
- }).on(txn)
-
- # Update existing ones
- updates = set(details.keys()) & set(old_details.keys())
- for key in updates:
- yield Update(
- {
- cm.CALENDAR_RESOURCE_ID: details[key].localID,
- cm.LAST_SYNC_TOKEN: details[key].lastSyncToken,
- },
- Where=(cm.CALENDAR_HOME_RESOURCE_ID == self.homeId).And(
- cm.REMOTE_RESOURCE_ID == key
- )
- ).on(txn)
-
-
</del><span class="cx"> @inTransactionWrapper
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def purgeLocal(self, txn, local_sync_state, remote_sync_state):
</span><span class="lines">@@ -398,15 +369,12 @@
</span><span class="cx"> """
</span><span class="cx"> home = yield txn.calendarHomeWithUID(self.migratingUid())
</span><span class="cx"> for remoteID in set(local_sync_state.keys()) - set(remote_sync_state.keys()):
</span><del>- calendar = yield home.childWithID(local_sync_state[remoteID].localID)
</del><ins>+ calendar = yield home.childWithID(local_sync_state[remoteID].localResourceID)
</ins><span class="cx"> if calendar is not None:
</span><span class="cx"> yield calendar.purge()
</span><span class="cx"> del local_sync_state[remoteID]
</span><span class="cx">
</span><del>- # FIXME: does this need to be done since we have a cascade on the table?
- # yield self.setSyncState(local_sync_state, txn=txn)
</del><span class="cx">
</span><del>-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def syncCalendar(self, remoteID, local_sync_state, remote_sync_state):
</span><span class="cx"> """
</span><span class="lines">@@ -422,26 +390,27 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # See if we need to create the local one first
</span><del>- local_state = local_sync_state.get(remoteID)
- if local_state is None:
</del><ins>+ if remoteID not in local_sync_state:
</ins><span class="cx"> localID = yield self.newCalendar()
</span><del>- local_sync_state[remoteID] = self.CalendarSyncState(localID, None)
</del><ins>+ local_sync_state[remoteID] = CalendarMigrationRecord.make(
+ calendarHomeResourceID=self.homeId,
+ remoteResourceID=remoteID,
+ localResourceID=localID,
+ lastSyncToken=None,
+ )
+ local_record = local_sync_state.get(remoteID)
</ins><span class="cx">
</span><del>- localID = local_sync_state.get(remoteID).localID
- local_token = local_sync_state.get(remoteID).lastSyncToken
-
</del><span class="cx"> remote_token = remote_sync_state[remoteID].lastSyncToken
</span><del>- if local_token != remote_token:
</del><ins>+ if local_record.lastSyncToken != remote_token:
</ins><span class="cx"> # Sync meta-data such as name, alarms, supported-components, transp, etc
</span><del>- yield self.syncCalendarMetaData(localID, remoteID)
</del><ins>+ yield self.syncCalendarMetaData(local_record)
</ins><span class="cx">
</span><span class="cx"> # Sync object resources
</span><del>- changed, deleted = yield self.findObjectsToSync(localID, remoteID, local_token)
- yield self.purgeDeletedObjectsInBatches(localID, deleted)
- yield self.updateChangedObjectsInBatches(localID, remoteID, changed)
</del><ins>+ changed, deleted = yield self.findObjectsToSync(local_record)
+ yield self.purgeDeletedObjectsInBatches(local_record, deleted)
+ yield self.updateChangedObjectsInBatches(local_record, changed)
</ins><span class="cx">
</span><del>- local_sync_state[remoteID] = self.CalendarSyncState(localID, remote_token)
- yield self.setSyncState(local_sync_state)
</del><ins>+ yield self.updateSyncState(local_record, remote_token)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inTransactionWrapper
</span><span class="lines">@@ -459,54 +428,48 @@
</span><span class="cx">
</span><span class="cx"> @inTransactionWrapper
</span><span class="cx"> @inlineCallbacks
</span><del>- def syncCalendarMetaData(self, txn, localID, remoteID):
</del><ins>+ def syncCalendarMetaData(self, txn, migrationRecord):
</ins><span class="cx"> """
</span><span class="cx"> Sync the metadata of a calendar from the remote side.
</span><span class="cx">
</span><del>- @param localID: id of the local calendar to sync
- @type localID: L{int}
- @param remoteID: id of the remote calendar to sync with
- @type remoteID: L{int}
</del><ins>+ @param migrationRecord: current migration record
+ @type localID: L{CalendarMigrationRecord}
</ins><span class="cx"> """
</span><span class="cx"> # Remote changes
</span><span class="cx"> remote_home = yield self._remoteHome(txn)
</span><del>- remote_calendar = yield remote_home.childWithID(remoteID)
</del><ins>+ remote_calendar = yield remote_home.childWithID(migrationRecord.remoteResourceID)
</ins><span class="cx"> if remote_calendar is None:
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><span class="cx"> # Check whether the deleted set items
</span><span class="cx"> local_home = yield txn.calendarHomeWithUID(self.migratingUid())
</span><del>- local_calendar = yield local_home.childWithID(localID)
</del><ins>+ local_calendar = yield local_home.childWithID(migrationRecord.localResourceID)
</ins><span class="cx"> yield local_calendar.copyMetadata(remote_calendar)
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inTransactionWrapper
</span><span class="cx"> @inlineCallbacks
</span><del>- def findObjectsToSync(self, txn, localID, remoteID, local_token):
</del><ins>+ def findObjectsToSync(self, txn, migrationRecord):
</ins><span class="cx"> """
</span><span class="cx"> Find the set of object resources that need to be sync'd from the remote
</span><span class="cx"> side and the set that need to be removed locally. Take into account the
</span><span class="cx"> possibility that this is a partial sync and removals or additions might
</span><span class="cx"> be false positives.
</span><span class="cx">
</span><del>- @param localID: id of the local calendar to sync
- @type localID: L{int}
- @param remoteID: id of the remote calendar to sync with
- @type remoteID: L{int}
- @param local_token: sync token last used to sync the calendar
- @type local_token: L{str}
</del><ins>+ @param migrationRecord: current migration record
+ @type localID: L{CalendarMigrationRecord}
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # Remote changes
</span><span class="cx"> remote_home = yield self._remoteHome(txn)
</span><del>- remote_calendar = yield remote_home.childWithID(remoteID)
</del><ins>+ remote_calendar = yield remote_home.childWithID(migrationRecord.remoteResourceID)
</ins><span class="cx"> if remote_calendar is None:
</span><span class="cx"> returnValue(None)
</span><del>- changed, deleted, _ignore_invalid = yield remote_calendar.resourceNamesSinceToken(local_token)
</del><ins>+ changed, deleted, _ignore_invalid = yield remote_calendar.resourceNamesSinceToken(migrationRecord.lastSyncToken)
</ins><span class="cx">
</span><span class="cx"> # Check whether the deleted set items
</span><span class="cx"> local_home = yield txn.calendarHomeWithUID(self.migratingUid())
</span><del>- local_calendar = yield local_home.childWithID(localID)
</del><ins>+ local_calendar = yield local_home.childWithID(migrationRecord.localResourceID)
</ins><span class="cx">
</span><span class="cx"> # Check the md5's on each changed remote with the local one to filter out ones
</span><span class="cx"> # we don't actually need to sync
</span><span class="lines">@@ -525,21 +488,21 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def purgeDeletedObjectsInBatches(self, localID, deleted):
</del><ins>+ def purgeDeletedObjectsInBatches(self, migrationRecord, deleted):
</ins><span class="cx"> """
</span><span class="cx"> Purge (silently remove) the specified object resources. This needs to
</span><span class="cx"> succeed in the case where some or all resources have already been deleted.
</span><span class="cx"> Do this in batches to keep transaction times small.
</span><span class="cx">
</span><del>- @param localID: id of the local calendar to sync
- @type localID: L{int}
</del><ins>+ @param migrationRecord: local calendar migration record
+ @type migrationRecord: L{CalendarMigrationRecord}
</ins><span class="cx"> @param deleted: list of names to purge
</span><span class="cx"> @type deleted: L{list} of L{str}
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> remaining = list(deleted)
</span><span class="cx"> while remaining:
</span><del>- yield self.purgeBatch(localID, remaining[:self.BATCH_SIZE])
</del><ins>+ yield self.purgeBatch(migrationRecord.localResourceID, remaining[:self.BATCH_SIZE])
</ins><span class="cx"> del remaining[:self.BATCH_SIZE]
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -567,23 +530,25 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def updateChangedObjectsInBatches(self, localID, remoteID, changed):
</del><ins>+ def updateChangedObjectsInBatches(self, migrationRecord, changed):
</ins><span class="cx"> """
</span><span class="cx"> Update the specified object resources. This needs to succeed in the
</span><span class="cx"> case where some or all resources have already been deleted.
</span><span class="cx"> Do this in batches to keep transaction times small.
</span><span class="cx">
</span><del>- @param localID: id of the local calendar to sync
- @type localID: L{int}
- @param remoteID: id of the remote calendar to sync with
- @type remoteID: L{int}
</del><ins>+ @param migrationRecord: local calendar migration record
+ @type migrationRecord: L{CalendarMigrationRecord}
</ins><span class="cx"> @param changed: list of names to update
</span><span class="cx"> @type changed: L{list} of L{str}
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> remaining = list(changed)
</span><span class="cx"> while remaining:
</span><del>- yield self.updateBatch(localID, remoteID, remaining[:self.BATCH_SIZE])
</del><ins>+ yield self.updateBatch(
+ migrationRecord.localResourceID,
+ migrationRecord.remoteResourceID,
+ remaining[:self.BATCH_SIZE],
+ )
</ins><span class="cx"> del remaining[:self.BATCH_SIZE]
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -622,7 +587,6 @@
</span><span class="cx"> # matches the remote one (which should help reduce the need for a client to resync
</span><span class="cx"> # the data when moved from one pod to the other).
</span><span class="cx"> txn._migrating = True
</span><del>- com = schema.CALENDAR_OBJECT_MIGRATION
</del><span class="cx"> for obj_name in remote_objects.keys():
</span><span class="cx"> remote_object = remote_objects[obj_name]
</span><span class="cx"> remote_data = yield remote_object.component()
</span><span class="lines">@@ -636,13 +600,12 @@
</span><span class="cx">
</span><span class="cx"> # Maintain the mapping from the remote to local id. Note that this mapping never changes as the ids on both
</span><span class="cx"> # sides are immutable - though it may get deleted if the local object is removed during sync (via a cascade).
</span><del>- yield Insert(
- {
- com.CALENDAR_HOME_RESOURCE_ID: self.homeId,
- com.REMOTE_RESOURCE_ID: remote_object.id(),
- com.LOCAL_RESOURCE_ID: local_object.id()
- }
- ).on(txn)
</del><ins>+ yield CalendarObjectMigrationRecord.create(
+ txn,
+ calendarHomeResourceID=self.homeId,
+ remoteResourceID=remote_object.id(),
+ localResourceID=local_object.id()
+ )
</ins><span class="cx">
</span><span class="cx"> # Sync meta-data such as schedule object, schedule tags, access mode etc
</span><span class="cx"> yield local_object.copyMetadata(remote_object)
</span><span class="lines">@@ -684,25 +647,20 @@
</span><span class="cx"> lmap = dict([(attachment.id(), attachment) for attachment in lattachments])
</span><span class="cx">
</span><span class="cx"> # Figure out the differences
</span><del>- am = schema.ATTACHMENT_MIGRATION
- rows = yield Select(
- [am.REMOTE_RESOURCE_ID, am.LOCAL_RESOURCE_ID],
- From=am,
- Where=(am.CALENDAR_HOME_RESOURCE_ID == self.homeId),
- ).on(txn)
- mapping = dict(rows)
</del><ins>+ records = yield AttachmentMigrationRecord.querysimple(
+ txn, calendarHomeResourceID=self.homeId
+ )
+ mapping = dict([(record.remoteResourceID, record) for record in records])
</ins><span class="cx">
</span><span class="cx"> # Removed - remove attachment and migration state
</span><span class="cx"> removed = set(mapping.keys()) - set(rmap.keys())
</span><span class="cx"> for remove_id in removed:
</span><del>- local_id = mapping[remove_id]
- att = yield ManagedAttachment.load(txn, None, None, attachmentID=local_id)
</del><ins>+ record = mapping[remove_id]
+ att = yield ManagedAttachment.load(txn, None, None, attachmentID=record.localResourceID)
</ins><span class="cx"> if att:
</span><span class="cx"> yield att.remove(adjustQuota=False)
</span><del>- yield Delete(
- From=am,
- Where=(am.LOCAL_RESOURCE_ID == local_id),
- ).on(txn)
</del><ins>+ else:
+ yield record.delete()
</ins><span class="cx">
</span><span class="cx"> # Track which ones need attachment data sync'd over
</span><span class="cx"> data_ids = set()
</span><span class="lines">@@ -711,19 +669,18 @@
</span><span class="cx"> added = set(rmap.keys()) - set(mapping.keys())
</span><span class="cx"> for added_id in added:
</span><span class="cx"> attachment = yield ManagedAttachment._create(txn, None, self.homeId)
</span><del>- yield Insert(
- {
- am.CALENDAR_HOME_RESOURCE_ID: self.homeId,
- am.REMOTE_RESOURCE_ID: added_id,
- am.LOCAL_RESOURCE_ID: attachment.id(),
- }
- ).on(txn)
</del><ins>+ yield AttachmentMigrationRecord.create(
+ txn,
+ calendarHomeResourceID=self.homeId,
+ remoteResourceID=added_id,
+ localResourceID=attachment.id(),
+ )
</ins><span class="cx"> data_ids.add(attachment.id())
</span><span class="cx">
</span><span class="cx"> # Possible updates - check for md5 change and sync
</span><span class="cx"> updates = set(mapping.keys()) & set(rmap.keys())
</span><span class="cx"> for updated_id in updates:
</span><del>- local_id = mapping[updated_id]
</del><ins>+ local_id = mapping[updated_id].localResourceID
</ins><span class="cx"> if rmap[updated_id].md5() != lmap[local_id].md5():
</span><span class="cx"> yield lmap[local_id].copyRemote(rmap[updated_id])
</span><span class="cx"> data_ids.add(local_id)
</span><span class="lines">@@ -744,21 +701,14 @@
</span><span class="cx"> if attachment is None:
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><del>- am = schema.ATTACHMENT_MIGRATION
- rows = yield Select(
- [am.LOCAL_RESOURCE_ID, am.REMOTE_RESOURCE_ID],
- From=am,
- Where=(am.CALENDAR_HOME_RESOURCE_ID == self.homeId),
- ).on(txn)
- mapping = dict(rows)
- remote_id = mapping.get(local_id)
- if remote_id is None:
- returnValue(None)
</del><ins>+ records = yield AttachmentMigrationRecord.querysimple(
+ txn, calendarHomeResourceID=self.homeId, localResourceID=local_id
+ )
+ if records:
+ # Read the data from the conduit
+ yield remote_home.readAttachmentData(records[0].remoteResourceID, attachment)
</ins><span class="cx">
</span><del>- # Read the data from the conduit
- yield remote_home.readAttachmentData(remote_id, attachment)
</del><span class="cx">
</span><del>-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def linkAttachments(self):
</span><span class="cx"> """
</span><span class="lines">@@ -801,21 +751,15 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # Get migration mappings
</span><del>- am = schema.ATTACHMENT_MIGRATION
- rows = yield Select(
- [am.REMOTE_RESOURCE_ID, am.LOCAL_RESOURCE_ID],
- From=am,
- Where=(am.CALENDAR_HOME_RESOURCE_ID == self.homeId),
- ).on(txn)
- attachmentIDMap = dict(rows)
</del><ins>+ records = yield AttachmentMigrationRecord.querysimple(
+ txn, calendarHomeResourceID=self.homeId
+ )
+ attachmentIDMap = dict([(record.remoteResourceID, record) for record in records])
</ins><span class="cx">
</span><del>- com = schema.CALENDAR_OBJECT_MIGRATION
- rows = yield Select(
- [com.REMOTE_RESOURCE_ID, com.LOCAL_RESOURCE_ID],
- From=com,
- Where=(com.CALENDAR_HOME_RESOURCE_ID == self.homeId),
- ).on(txn)
- objectIDMap = dict(rows)
</del><ins>+ records = yield CalendarObjectMigrationRecord.querysimple(
+ txn, calendarHomeResourceID=self.homeId
+ )
+ objectIDMap = dict([(record.remoteResourceID, record) for record in records])
</ins><span class="cx">
</span><span class="cx"> returnValue((attachmentIDMap, objectIDMap,))
</span><span class="cx">
</span><span class="lines">@@ -832,7 +776,7 @@
</span><span class="cx"> link._txn = txn
</span><span class="cx">
</span><span class="cx"> # Now re-map the attachment ID and calendar_object_id to the local ones
</span><del>- link._attachmentID = attachmentIDMap[link._attachmentID]
- link._calendarObjectID = objectIDMap[link._calendarObjectID]
</del><ins>+ link._attachmentID = attachmentIDMap[link._attachmentID].localResourceID
+ link._calendarObjectID = objectIDMap[link._calendarObjectID].localResourceID
</ins><span class="cx">
</span><span class="cx"> yield link.insert()
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationmigration_metadatapy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/migration_metadata.py (0 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/migration_metadata.py         (rev 0)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/migration_metadata.py        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from twext.enterprise.dal.record import Record, fromTable
+from txdav.common.datastore.sql_tables import schema
+from twext.enterprise.dal.syntax import Parameter, Delete
+from twisted.internet.defer import inlineCallbacks
+
+"""
+Module that manages store-level metadata objects used during the migration process.
+"""
+
+class CalendarMigrationRecord(Record, fromTable(schema.CALENDAR_MIGRATION)):
+ """
+ @DynamicAttrs
+ L{Record} for L{schema.CALENDAR_MIGRATION}.
+ """
+
+ @classmethod
+ @inlineCallbacks
+ def deleteremotes(cls, txn, homeid, remotes):
+ return Delete(
+ From=cls.table,
+ Where=(cls.calendarHomeResourceID == homeid).And(
+ cls.remoteResourceID.In(Parameter("remotes", len(remotes)))
+ ),
+ ).on(txn, remotes=remotes)
+
+
+
+class CalendarObjectMigrationRecord(Record, fromTable(schema.CALENDAR_OBJECT_MIGRATION)):
+ """
+ @DynamicAttrs
+ L{Record} for L{schema.CALENDAR_OBJECT_MIGRATION}.
+ """
+ pass
+
+
+
+class AttachmentMigrationRecord(Record, fromTable(schema.ATTACHMENT_MIGRATION)):
+ """
+ @DynamicAttrs
+ L{Record} for L{schema.ATTACHMENT_MIGRATION}.
+ """
+ pass
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtesttest_home_syncpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> from twistedcaldav.ical import Component, normalize_iCalStr
</span><span class="cx"> from txdav.caldav.datastore.sql import ManagedAttachment
</span><span class="cx"> from txdav.common.datastore.podding.migration.home_sync import CrossPodHomeSync
</span><ins>+from txdav.common.datastore.podding.migration.migration_metadata import CalendarMigrationRecord
</ins><span class="cx"> from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
</span><span class="cx"> from txdav.common.datastore.sql_tables import schema
</span><span class="cx"> from txweb2.http_headers import MimeType
</span><span class="lines">@@ -191,7 +192,13 @@
</span><span class="cx"> for calendar in calendars01:
</span><span class="cx"> if calendar.owned():
</span><span class="cx"> sync_token = yield calendar.syncToken()
</span><del>- results01[calendar.id()] = CrossPodHomeSync.CalendarSyncState(0, sync_token)
</del><ins>+ results01[calendar.id()] = CalendarMigrationRecord.make(
+ calendarHomeResourceID=home01.id(),
+ remoteResourceID=calendar.id(),
+ localResourceID=0,
+ lastSyncToken=sync_token,
+ )
+
</ins><span class="cx"> yield self.commitTransaction(0)
</span><span class="cx">
</span><span class="cx"> syncer = CrossPodHomeSync(self.theStoreUnderTest(1), "user01")
</span><span class="lines">@@ -225,7 +232,12 @@
</span><span class="cx">
</span><span class="cx"> # Trigger sync of the one calendar
</span><span class="cx"> local_sync_state = {}
</span><del>- remote_sync_state = {remote_id: CrossPodHomeSync.CalendarSyncState(0, remote_sync_token)}
</del><ins>+ remote_sync_state = {remote_id: CalendarMigrationRecord.make(
+ calendarHomeResourceID=home0.id(),
+ remoteResourceID=remote_id,
+ localResourceID=0,
+ lastSyncToken=remote_sync_token,
+ )}
</ins><span class="cx"> yield syncer.syncCalendar(
</span><span class="cx"> remote_id,
</span><span class="cx"> local_sync_state,
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_directorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_directory.py (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_directory.py        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_directory.py        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> def removeMemberFromGroup(self, memberUID, groupID):
</span><del>- return GroupMembershipRecord.deletematch(
</del><ins>+ return GroupMembershipRecord.deletesimple(
</ins><span class="cx"> self, groupID=groupID, memberUID=memberUID.encode("utf-8")
</span><span class="cx"> )
</span><span class="cx">
</span><span class="lines">@@ -499,12 +499,11 @@
</span><span class="cx"> read-only access
</span><span class="cx"> @type readWrite: C{boolean}
</span><span class="cx"> """
</span><del>- return DelegateRecord.deletesome(
</del><ins>+ return DelegateRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- (DelegateRecord.delegator == delegator.encode("utf-8")).And(
- DelegateRecord.delegate == delegate.encode("utf-8")).And(
- DelegateRecord.readWrite == (1 if readWrite else 0)
- ),
</del><ins>+ delegator=delegator.encode("utf-8"),
+ delegate=delegate.encode("utf-8"),
+ readWrite=(1 if readWrite else 0),
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -519,11 +518,10 @@
</span><span class="cx"> read-only access
</span><span class="cx"> @type readWrite: C{boolean}
</span><span class="cx"> """
</span><del>- return DelegateRecord.deletesome(
</del><ins>+ return DelegateRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- (DelegateRecord.delegator == delegator.encode("utf-8")).And(
- DelegateRecord.readWrite == (1 if readWrite else 0)
- ),
</del><ins>+ delegator=delegator.encode("utf-8"),
+ readWrite=(1 if readWrite else 0)
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -540,12 +538,11 @@
</span><span class="cx"> read-only access
</span><span class="cx"> @type readWrite: C{boolean}
</span><span class="cx"> """
</span><del>- return DelegateGroupsRecord.deletesome(
</del><ins>+ return DelegateGroupsRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- (DelegateGroupsRecord.delegator == delegator.encode("utf-8")).And(
- DelegateGroupsRecord.groupID == delegateGroupID).And(
- DelegateGroupsRecord.readWrite == (1 if readWrite else 0)
- ),
</del><ins>+ delegator=delegator.encode("utf-8"),
+ groupID=delegateGroupID,
+ readWrite=(1 if readWrite else 0),
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -560,11 +557,10 @@
</span><span class="cx"> read-only access
</span><span class="cx"> @type readWrite: C{boolean}
</span><span class="cx"> """
</span><del>- return DelegateGroupsRecord.deletesome(
</del><ins>+ return DelegateGroupsRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- (DelegateGroupsRecord.delegator == delegator.encode("utf-8")).And(
- DelegateGroupsRecord.readWrite == (1 if readWrite else 0)
- ),
</del><ins>+ delegator=delegator.encode("utf-8"),
+ readWrite=(1 if readWrite else 0),
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -734,17 +730,16 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # Delete existing external assignments for the delegator
</span><del>- yield DelegateGroupsRecord.deletesome(
</del><ins>+ yield DelegateGroupsRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- (DelegateGroupsRecord.delegator == str(delegator)).And(
- DelegateGroupsRecord.isExternal == 1
- )
</del><ins>+ delegator=str(delegator),
+ isExternal=1,
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> # Remove from the external comparison table
</span><del>- yield ExternalDelegateGroupsRecord.deletesome(
</del><ins>+ yield ExternalDelegateGroupsRecord.deletesimple(
</ins><span class="cx"> self,
</span><del>- ExternalDelegateGroupsRecord.delegator == str(delegator)
</del><ins>+ delegator=str(delegator),
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> # Store new assignments in the external comparison table
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> create table CALENDAR_MIGRATION (
</span><span class="cx"> "CALENDAR_HOME_RESOURCE_ID" integer references CALENDAR_HOME on delete cascade,
</span><span class="cx"> "REMOTE_RESOURCE_ID" integer not null,
</span><del>- "CALENDAR_RESOURCE_ID" integer references CALENDAR on delete cascade,
</del><ins>+ "LOCAL_RESOURCE_ID" integer references CALENDAR on delete cascade,
</ins><span class="cx"> "LAST_SYNC_TOKEN" nvarchar2(255),
</span><span class="cx"> primary key ("CALENDAR_HOME_RESOURCE_ID", "REMOTE_RESOURCE_ID")
</span><span class="cx"> );
</span><span class="lines">@@ -647,8 +647,8 @@
</span><span class="cx"> DEFAULT_POLLS
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index CALENDAR_MIGRATION_CA_cc68f4ec on CALENDAR_MIGRATION (
- CALENDAR_RESOURCE_ID
</del><ins>+create index CALENDAR_MIGRATION_LO_0525c72b on CALENDAR_MIGRATION (
+ LOCAL_RESOURCE_ID
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current.sql (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current.sql        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/current.sql        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -141,16 +141,16 @@
</span><span class="cx"> ------------------------
</span><span class="cx">
</span><span class="cx"> create table CALENDAR_MIGRATION (
</span><del>- CALENDAR_HOME_RESOURCE_ID        integer references CALENDAR_HOME on delete cascade,
</del><ins>+ CALENDAR_HOME_RESOURCE_ID                integer references CALENDAR_HOME on delete cascade,
</ins><span class="cx"> REMOTE_RESOURCE_ID                        integer not null,
</span><del>- CALENDAR_RESOURCE_ID                        integer        references CALENDAR on delete cascade,
</del><ins>+ LOCAL_RESOURCE_ID                                integer        references CALENDAR on delete cascade,
</ins><span class="cx"> LAST_SYNC_TOKEN                                varchar(255),
</span><span class="cx">
</span><span class="cx"> primary key (CALENDAR_HOME_RESOURCE_ID, REMOTE_RESOURCE_ID) -- implicit index
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index CALENDAR_MIGRATION_CALENDAR_RESOURCE_ID on
- CALENDAR_MIGRATION(CALENDAR_RESOURCE_ID);
</del><ins>+create index CALENDAR_MIGRATION_LOCAL_RESOURCE_ID on
+ CALENDAR_MIGRATION(LOCAL_RESOURCE_ID);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> ---------------------------
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_51_to_52sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_51_to_52.sql        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -25,13 +25,13 @@
</span><span class="cx"> create table CALENDAR_MIGRATION (
</span><span class="cx"> "CALENDAR_HOME_RESOURCE_ID" integer references CALENDAR_HOME on delete cascade,
</span><span class="cx"> "REMOTE_RESOURCE_ID" integer not null,
</span><del>- "CALENDAR_RESOURCE_ID" integer references CALENDAR on delete cascade,
</del><ins>+ "LOCAL_RESOURCE_ID" integer references CALENDAR on delete cascade,
</ins><span class="cx"> "LAST_SYNC_TOKEN" nvarchar2(255),
</span><span class="cx"> primary key ("CALENDAR_HOME_RESOURCE_ID", "REMOTE_RESOURCE_ID")
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index CALENDAR_MIGRATION_CA_cc68f4ec on CALENDAR_MIGRATION (
- CALENDAR_RESOURCE_ID
</del><ins>+create index CALENDAR_MIGRATION_LO_0525c72b on CALENDAR_MIGRATION (
+ LOCAL_RESOURCE_ID
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> -- New table
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_51_to_52sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_51_to_52.sql (14418 => 14419)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_51_to_52.sql        2015-02-17 00:04:44 UTC (rev 14418)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_51_to_52.sql        2015-02-17 00:08:14 UTC (rev 14419)
</span><span class="lines">@@ -23,16 +23,16 @@
</span><span class="cx">
</span><span class="cx"> -- New table
</span><span class="cx"> create table CALENDAR_MIGRATION (
</span><del>- CALENDAR_HOME_RESOURCE_ID        integer references CALENDAR_HOME on delete cascade,
</del><ins>+ CALENDAR_HOME_RESOURCE_ID                integer references CALENDAR_HOME on delete cascade,
</ins><span class="cx"> REMOTE_RESOURCE_ID                        integer not null,
</span><del>- CALENDAR_RESOURCE_ID                        integer        references CALENDAR on delete cascade,
</del><ins>+ LOCAL_RESOURCE_ID                                integer        references CALENDAR on delete cascade,
</ins><span class="cx"> LAST_SYNC_TOKEN                                varchar(255),
</span><span class="cx">
</span><span class="cx"> primary key (CALENDAR_HOME_RESOURCE_ID, REMOTE_RESOURCE_ID) -- implicit index
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index CALENDAR_MIGRATION_CALENDAR_RESOURCE_ID on
- CALENDAR_MIGRATION(CALENDAR_RESOURCE_ID);
</del><ins>+create index CALENDAR_MIGRATION_LOCAL_RESOURCE_ID on
+ CALENDAR_MIGRATION(LOCAL_RESOURCE_ID);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> -- New table
</span></span></pre>
</div>
</div>
</body>
</html>