Path: blob/master/resources/sql/autopatches/20140211.dx.2.migcommenttext.php
12250 views
<?php12$conn_w = id(new DifferentialRevision())->establishConnection('w');3$rows = new LiskRawMigrationIterator($conn_w, 'differential_comment');45$content_source = PhabricatorContentSource::newForSource(6PhabricatorOldWorldContentSource::SOURCECONST)->serialize();78echo pht('Migrating Differential comment text to modern storage...')."\n";9foreach ($rows as $row) {10$id = $row['id'];11echo pht('Migrating Differential comment %d...', $id)."\n";12if (!strlen($row['content'])) {13echo pht('Comment has no text, continuing.')."\n";14continue;15}1617$revision = id(new DifferentialRevision())->load($row['revisionID']);18if (!$revision) {19echo pht('Comment has no valid revision, continuing.')."\n";20continue;21}2223$revision_phid = $revision->getPHID();2425$dst_table = 'differential_inline_comment';2627$xaction_phid = PhabricatorPHID::generateNewPHID(28PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,29DifferentialRevisionPHIDType::TYPECONST);3031$comment_phid = PhabricatorPHID::generateNewPHID(32PhabricatorPHIDConstants::PHID_TYPE_XCMT,33DifferentialRevisionPHIDType::TYPECONST);3435queryfx(36$conn_w,37'INSERT IGNORE INTO %T38(phid, transactionPHID, authorPHID, viewPolicy, editPolicy,39commentVersion, content, contentSource, isDeleted,40dateCreated, dateModified, revisionPHID, changesetID,41legacyCommentID)42VALUES (%s, %s, %s, %s, %s,43%d, %s, %s, %d,44%d, %d, %s, %nd,45%d)',46'differential_transaction_comment',4748// phid, transactionPHID, authorPHID, viewPolicy, editPolicy49$comment_phid,50$xaction_phid,51$row['authorPHID'],52'public',53$row['authorPHID'],5455// commentVersion, content, contentSource, isDeleted561,57$row['content'],58$content_source,590,6061// dateCreated, dateModified, revisionPHID, changesetID, legacyCommentID62$row['dateCreated'],63$row['dateModified'],64$revision_phid,65null,66$row['id']);67}6869echo pht('Done.')."\n";707172