mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Add storage for new audit transactions and comments
Summary: Ref T4896. This adds the new storage, without any code changes. This storage is substantially identical to the Differential storage, except that `changesetID` has been replaced by `pathID`. I've retained the properties intended to be used to implement T1460. They might not be quite right, but at least we'll be able to make any fixes consistently to both applications. For now, these fields are empty and ignored. Test Plan: Ran `./bin/storage upgrade`. Nothing calls this code yet. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T4896 Differential Revision: https://secure.phabricator.com/D10017
This commit is contained in:
parent
8605a1808d
commit
416f3d9ede
6 changed files with 107 additions and 0 deletions
19
resources/sql/autopatches/20140722.audit.1.xactions.sql
Normal file
19
resources/sql/autopatches/20140722.audit.1.xactions.sql
Normal file
|
@ -0,0 +1,19 @@
|
|||
CREATE TABLE {$NAMESPACE}_audit.audit_transaction (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
phid VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
authorPHID VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
objectPHID VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
viewPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
editPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
commentPHID VARCHAR(64) COLLATE utf8_bin DEFAULT NULL,
|
||||
commentVersion INT UNSIGNED NOT NULL,
|
||||
transactionType VARCHAR(32) COLLATE utf8_bin NOT NULL,
|
||||
oldValue LONGTEXT COLLATE utf8_bin NOT NULL,
|
||||
newValue LONGTEXT COLLATE utf8_bin NOT NULL,
|
||||
contentSource LONGTEXT COLLATE utf8_bin NOT NULL,
|
||||
metadata LONGTEXT COLLATE utf8_bin NOT NULL,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
UNIQUE KEY `key_phid` (`phid`),
|
||||
KEY `key_object` (`objectPHID`)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
29
resources/sql/autopatches/20140722.audit.2.comments.sql
Normal file
29
resources/sql/autopatches/20140722.audit.2.comments.sql
Normal file
|
@ -0,0 +1,29 @@
|
|||
CREATE TABLE {$NAMESPACE}_audit.audit_transaction_comment (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
phid VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
transactionPHID VARCHAR(64) COLLATE utf8_bin,
|
||||
authorPHID VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
viewPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
editPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL,
|
||||
commentVersion INT UNSIGNED NOT NULL,
|
||||
content longtext COLLATE utf8_bin NOT NULL,
|
||||
contentSource longtext COLLATE utf8_bin NOT NULL,
|
||||
isDeleted BOOL NOT NULL,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
commitPHID VARCHAR(64) COLLATE utf8_bin,
|
||||
pathID INT UNSIGNED,
|
||||
isNewFile BOOL NOT NULL,
|
||||
lineNumber INT UNSIGNED NOT NULL,
|
||||
lineLength INT UNSIGNED NOT NULL,
|
||||
fixedState VARCHAR(12) COLLATE utf8_bin,
|
||||
hasReplies BOOL NOT NULL,
|
||||
replyToCommentPHID VARCHAR(64) COLLATE utf8_bin,
|
||||
legacyCommentID INT UNSIGNED,
|
||||
UNIQUE KEY `key_phid` (phid),
|
||||
UNIQUE KEY `key_version` (transactionPHID, commentVersion),
|
||||
KEY `key_path` (pathID),
|
||||
KEY `key_draft` (authorPHID, transactionPHID),
|
||||
KEY `key_commit` (commitPHID),
|
||||
KEY `key_legacy` (legacyCommentID)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
|
@ -1148,6 +1148,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuditPreviewController' => 'applications/audit/controller/PhabricatorAuditPreviewController.php',
|
||||
'PhabricatorAuditReplyHandler' => 'applications/audit/mail/PhabricatorAuditReplyHandler.php',
|
||||
'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php',
|
||||
'PhabricatorAuditTransaction' => 'applications/audit/storage/PhabricatorAuditTransaction.php',
|
||||
'PhabricatorAuditTransactionComment' => 'applications/audit/storage/PhabricatorAuditTransactionComment.php',
|
||||
'PhabricatorAuditTransactionQuery' => 'applications/audit/query/PhabricatorAuditTransactionQuery.php',
|
||||
'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php',
|
||||
'PhabricatorAuthApplication' => 'applications/auth/application/PhabricatorAuthApplication.php',
|
||||
'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php',
|
||||
|
@ -3940,6 +3943,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||
'PhabricatorAuditPreviewController' => 'PhabricatorAuditController',
|
||||
'PhabricatorAuditReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'PhabricatorAuditTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhabricatorAuditTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||
'PhabricatorAuditTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhabricatorAuthAccountView' => 'AphrontView',
|
||||
'PhabricatorAuthApplication' => 'PhabricatorApplication',
|
||||
'PhabricatorAuthAuthFactorPHIDType' => 'PhabricatorPHIDType',
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuditTransactionQuery
|
||||
extends PhabricatorApplicationTransactionQuery {
|
||||
|
||||
public function getTemplateApplicationTransaction() {
|
||||
return new PhabricatorAuditTransaction();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuditTransaction
|
||||
extends PhabricatorApplicationTransaction {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'audit';
|
||||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorRepositoryCommitPHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
return new PhabricatorAuditTransactionComment();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuditTransactionComment
|
||||
extends PhabricatorApplicationTransactionComment {
|
||||
|
||||
protected $commitPHID;
|
||||
protected $pathID;
|
||||
protected $isNewFile = 0;
|
||||
protected $lineNumber = 0;
|
||||
protected $lineLength = 0;
|
||||
protected $fixedState;
|
||||
protected $hasReplies = 0;
|
||||
protected $replyToCommentPHID;
|
||||
protected $legacyCommentID;
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return new PhabricatorAuditTransaction();
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
// Only cache submitted comments.
|
||||
return ($this->getTransactionPHID() != null);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue