1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Generate expected schemata for Repository

Summary: Ref T1191. Add specs for repository tables.

Test Plan: Saw ~300 fewer schema warnings.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

Differential Revision: https://secure.phabricator.com/D10575
This commit is contained in:
epriestley 2014-09-28 15:12:21 -07:00
parent f74082aecd
commit b149cb7e99
16 changed files with 401 additions and 0 deletions

View file

@ -2143,6 +2143,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryRefCursorQuery' => 'applications/repository/query/PhabricatorRepositoryRefCursorQuery.php',
'PhabricatorRepositoryRefEngine' => 'applications/repository/engine/PhabricatorRepositoryRefEngine.php',
'PhabricatorRepositoryRepositoryPHIDType' => 'applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php',
'PhabricatorRepositorySchemaSpec' => 'applications/repository/storage/PhabricatorRepositorySchemaSpec.php',
'PhabricatorRepositorySearchEngine' => 'applications/repository/query/PhabricatorRepositorySearchEngine.php',
'PhabricatorRepositoryStatusMessage' => 'applications/repository/storage/PhabricatorRepositoryStatusMessage.php',
'PhabricatorRepositorySvnCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php',
@ -5139,6 +5140,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryRefCursorQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorRepositoryRefEngine' => 'PhabricatorRepositoryEngine',
'PhabricatorRepositoryRepositoryPHIDType' => 'PhabricatorPHIDType',
'PhabricatorRepositorySchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorRepositorySearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorRepositoryStatusMessage' => 'PhabricatorRepositoryDAO',
'PhabricatorRepositorySvnCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',

View file

@ -246,6 +246,11 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
$charset = 'binary';
$collation = 'binary';
break;
case 'bytes32':
$column_type = 'char(32)';
$charset = 'binary';
$collation = 'binary';
break;
case 'bytes12':
$column_type = 'char(12)';
$charset = 'binary';
@ -266,6 +271,11 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
$charset = $this->getUTF8Charset();
$collation = $this->getUTF8Collation();
break;
case 'text80':
$column_type = 'varchar(80)';
$charset = $this->getUTF8Charset();
$collation = $this->getUTF8Collation();
break;
case 'text64':
$column_type = 'varchar(64)';
$charset = $this->getUTF8Charset();

View file

@ -29,6 +29,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
const TABLE_BADCOMMIT = 'repository_badcommit';
const TABLE_LINTMESSAGE = 'repository_lintmessage';
const TABLE_PARENTS = 'repository_parents';
const TABLE_COVERAGE = 'repository_coverage';
const SERVE_OFF = 'off';
const SERVE_READONLY = 'readonly';
@ -77,6 +78,31 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'callsign' => 'text32',
'versionControlSystem' => 'text32',
'uuid' => 'text64?',
'pushPolicy' => 'policy',
'credentialPHID' => 'phid?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'callsign' => array(
'columns' => array('callsign'),
'unique' => true,
),
'key_name' => array(
'columns' => array('name'),
),
'key_vcs' => array(
'columns' => array('versionControlSystem'),
),
),
) + parent::getConfiguration();
}

View file

@ -22,6 +22,21 @@ final class PhabricatorRepositoryArcanistProject
'symbolIndexLanguages' => self::SERIALIZATION_JSON,
'symbolIndexProjects' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'repositoryID' => 'id?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'name' => array(
'columns' => array('name'),
'unique' => true,
),
),
) + parent::getConfiguration();
}

View file

@ -17,6 +17,17 @@ final class PhabricatorRepositoryAuditRequest
self::CONFIG_SERIALIZATION => array(
'auditReasons' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'auditStatus' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'commitPHID' => array(
'columns' => array('commitPHID'),
),
'auditorPHID' => array(
'columns' => array('auditorPHID', 'auditStatus'),
),
),
) + parent::getConfiguration();
}

View file

@ -6,6 +6,21 @@ final class PhabricatorRepositoryBranch extends PhabricatorRepositoryDAO {
protected $name;
protected $lintCommit;
public function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'lintCommit' => 'text40?',
),
self::CONFIG_KEY_SCHEMA => array(
'repositoryID' => array(
'columns' => array('repositoryID', 'name'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public static function loadBranch($repository_id, $branch_name) {
return id(new PhabricatorRepositoryBranch())->loadOneWhere(
'repositoryID = %d AND name = %s',

View file

@ -66,6 +66,34 @@ final class PhabricatorRepositoryCommit
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'commitIdentifier' => 'text40',
'mailKey' => 'bytes20',
'authorPHID' => 'phid?',
'auditStatus' => 'uint32',
'summary' => 'text80',
'importStatus' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'repositoryID' => array(
'columns' => array('repositoryID', 'importStatus'),
),
'authorPHID' => array(
'columns' => array('authorPHID', 'auditStatus', 'epoch'),
),
'repositoryID_2' => array(
'columns' => array('repositoryID', 'epoch'),
),
'key_commit_identity' => array(
'columns' => array('commitIdentifier', 'repositoryID'),
'unique' => true,
),
),
) + parent::getConfiguration();
}

View file

@ -19,6 +19,19 @@ final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
self::CONFIG_SERIALIZATION => array(
'commitDetails' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'authorName' => 'text255',
'commitMessage' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'commitID' => array(
'columns' => array('commitID'),
'unique' => true,
),
'authorName' => array(
'columns' => array('authorName'),
),
),
) + parent::getConfiguration();
}

View file

@ -17,6 +17,15 @@ final class PhabricatorRepositoryMirror extends PhabricatorRepositoryDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'remoteURI' => 'text255',
'credentialPHID' => 'phid?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_repository' => array(
'columns' => array('repositoryPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -28,6 +28,17 @@ final class PhabricatorRepositoryPushEvent
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'remoteAddress' => 'uint32?',
'remoteProtocol' => 'text32?',
'rejectCode' => 'uint32',
'rejectDetails' => 'text64?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_repository' => array(
'columns' => array('repositoryPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -71,6 +71,33 @@ final class PhabricatorRepositoryPushLog
self::CONFIG_BINARY => array(
'refNameRaw' => true,
),
self::CONFIG_COLUMN_SCHEMA => array(
'refType' => 'text12',
'refNameHash' => 'bytes12?',
'refNameRaw' => 'bytes?',
'refNameEncoding' => 'text16?',
'refOld' => 'text40?',
'refNew' => 'text40',
'mergeBase' => 'text40?',
'changeFlags' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_repository' => array(
'columns' => array('repositoryPHID'),
),
'key_ref' => array(
'columns' => array('repositoryPHID', 'refNew'),
),
'key_name' => array(
'columns' => array('repositoryPHID', 'refNameHash'),
),
'key_event' => array(
'columns' => array('pushEventPHID'),
),
'key_pusher' => array(
'columns' => array('pusherPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -27,6 +27,17 @@ final class PhabricatorRepositoryRefCursor extends PhabricatorRepositoryDAO
self::CONFIG_BINARY => array(
'refNameRaw' => true,
),
self::CONFIG_COLUMN_SCHEMA => array(
'refType' => 'text32',
'refNameHash' => 'bytes12',
'refNameEncoding' => 'text16',
'commitIdentifier' => 'text40',
),
self::CONFIG_KEY_SCHEMA => array(
'key_cursor' => array(
'columns' => array('repositoryPHID', 'refType', 'refNameHash'),
),
),
) + parent::getConfiguration();
}

View file

@ -0,0 +1,185 @@
<?php
final class PhabricatorRepositorySchemaSpec
extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildLiskSchemata('PhabricatorRepositoryDAO');
$this->buildEdgeSchemata(new PhabricatorRepository());
$this->buildTransactionSchema(
new PhabricatorRepositoryTransaction());
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_BADCOMMIT,
array(
'fullCommitName' => 'text255',
'description' => 'text',
),
array(
'PRIMARY' => array(
'columns' => array('fullCommitName'),
'unique' => true,
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_COVERAGE,
array(
'id' => 'id',
'branchID' => 'id',
'commitID' => 'id',
'pathID' => 'id',
'coverage' => 'bytes',
),
array(
'PRIMARY' => array(
'columns' => array('id'),
'unique' => true,
),
'key_path' => array(
'columns' => array('branchID', 'pathID', 'commitID'),
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_FILESYSTEM,
array(
'repositoryID' => 'id',
'parentID' => 'id',
'svnCommit' => 'uint32',
'pathID' => 'id',
'existed' => 'bool',
'fileType' => 'uint32',
),
array(
'PRIMARY' => array(
'columns' => array('repositoryID', 'parentID', 'pathID', 'svnCommit'),
'unique' => true,
),
'repositoryID' => array(
'columns' => array('repositoryID', 'svnCommit'),
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_LINTMESSAGE,
array(
'id' => 'id',
'branchID' => 'id',
'path' => 'text',
'line' => 'uint32',
'authorPHID' => 'phid?',
'code' => 'text32',
'severity' => 'text16',
'name' => 'text255',
'description' => 'text',
),
array(
'PRIMARY' => array(
'columns' => array('id'),
'unique' => true,
),
'branchID' => array(
'columns' => array('branchID', 'path(64)'),
),
'branchID_2' => array(
'columns' => array('branchID', 'code', 'path(64)'),
),
'key_author' => array(
'columns' => array('authorPHID'),
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_PARENTS,
array(
'id' => 'id',
'childCommitID' => 'id',
'parentCommitID' => 'id',
),
array(
'PRIMARY' => array(
'columns' => array('id'),
'unique' => true,
),
'key_child' => array(
'columns' => array('childCommitID', 'parentCommitID'),
'unique' => true,
),
'key_parent' => array(
'columns' => array('parentCommitID'),
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_PATH,
array(
'id' => 'id',
'path' => 'text',
'pathHash' => 'bytes32',
),
array(
'PRIMARY' => array(
'columns' => array('id'),
'unique' => true,
),
'pathHash' => array(
'columns' => array('pathHash'),
'unique' => true,
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_PATHCHANGE,
array(
'repositoryID' => 'id',
'pathID' => 'id',
'commitID' => 'id',
'targetPathID' => 'id?',
'targetCommitID' => 'id?',
'changeType' => 'uint32',
'fileType' => 'uint32',
'isDirect' => 'bool',
'commitSequence' => 'uint32',
),
array(
'PRIMARY' => array(
'columns' => array('commitID', 'pathID'),
'unique' => true,
),
'repositoryID' => array(
'columns' => array('repositoryID', 'pathID', 'commitSequence'),
),
));
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_SUMMARY,
array(
'repositoryID' => 'id',
'size' => 'uint32',
'lastCommitID' => 'id',
'epoch' => 'epoch?',
),
array(
'PRIMARY' => array(
'columns' => array('repositoryID'),
'unique' => true,
),
'key_epoch' => array(
'columns' => array('epoch'),
),
));
}
}

View file

@ -23,6 +23,16 @@ final class PhabricatorRepositoryStatusMessage
self::CONFIG_SERIALIZATION => array(
'parameters' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'statusType' => 'text32',
'statusCode' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
'repositoryID' => array(
'columns' => array('repositoryID', 'statusType'),
'unique' => true,
),
),
) + parent::getConfiguration();
}

View file

@ -24,6 +24,20 @@ final class PhabricatorRepositorySymbol extends PhabricatorRepositoryDAO {
return array(
self::CONFIG_IDS => self::IDS_MANUAL,
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'id' => null,
'symbolContext' => 'text128',
'symbolName' => 'text128',
'symbolType' => 'text12',
'symbolLanguage' => 'text32',
'lineNumber' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'PRIMARY' => null,
'symbolName' => array(
'columns' => array('symbolName'),
),
),
) + parent::getConfiguration();
}

View file

@ -6,6 +6,20 @@ final class PhabricatorRepositoryVCSPassword extends PhabricatorRepositoryDAO {
protected $userPHID;
protected $passwordHash;
public function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'passwordHash' => 'text128',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => array(
'columns' => array('userPHID'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public function setPassword(
PhutilOpaqueEnvelope $password,
PhabricatorUser $user) {