@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Generate expected schemata for User/People tables

Summary:
Ref T1191. Some notes here:

- Drops the old LDAP and OAuth info tables. These were migrated to the ExternalAccount table a very long time ago.
- Separates surplus/missing keys from other types of surplus/missing things. In the long run, my plan is to have only two notice levels:
- Error: something we can't fix (missing database, table, or column; overlong key).
- Warning: something we can fix (surplus anything, missing key, bad column type, bad key columns, bad uniqueness, bad collation or charset).
- For now, retaining three levels is helpful in generating all the expected scheamta.

Test Plan:
- Saw ~200 issues resolve, leaving ~1,300.
- Grepped for removed tables.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

Differential Revision: https://secure.phabricator.com/D10580

+284 -6
+1
resources/sql/autopatches/20140926.schema.03.dropldapinfo.sql
··· 1 + DROP TABLE {$NAMESPACE}_user.user_ldapinfo;
+1
resources/sql/autopatches/20140926.schema.04.dropoauthinfo.sql
··· 1 + DROP TABLE {$NAMESPACE}_user.user_oauthinfo;
+2
src/__phutil_library_map__.php
··· 2419 2419 'PhabricatorUserRealNameField' => 'applications/people/customfield/PhabricatorUserRealNameField.php', 2420 2420 'PhabricatorUserRolesField' => 'applications/people/customfield/PhabricatorUserRolesField.php', 2421 2421 'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php', 2422 + 'PhabricatorUserSchemaSpec' => 'applications/people/storage/PhabricatorUserSchemaSpec.php', 2422 2423 'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php', 2423 2424 'PhabricatorUserSinceField' => 'applications/people/customfield/PhabricatorUserSinceField.php', 2424 2425 'PhabricatorUserStatusField' => 'applications/people/customfield/PhabricatorUserStatusField.php', ··· 5417 5418 'PhabricatorUserRealNameField' => 'PhabricatorUserCustomField', 5418 5419 'PhabricatorUserRolesField' => 'PhabricatorUserCustomField', 5419 5420 'PhabricatorUserSSHKey' => 'PhabricatorUserDAO', 5421 + 'PhabricatorUserSchemaSpec' => 'PhabricatorConfigSchemaSpec', 5420 5422 'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 5421 5423 'PhabricatorUserSinceField' => 'PhabricatorUserCustomField', 5422 5424 'PhabricatorUserStatusField' => 'PhabricatorUserCustomField',
+20
src/applications/auth/storage/PhabricatorAuthSession.php
··· 19 19 public function getConfiguration() { 20 20 return array( 21 21 self::CONFIG_TIMESTAMPS => false, 22 + self::CONFIG_COLUMN_SCHEMA => array( 23 + 'type' => 'text32', 24 + 'sessionKey' => 'bytes40', 25 + 'sessionStart' => 'epoch', 26 + 'sessionExpires' => 'epoch', 27 + 'highSecurityUntil' => 'epoch?', 28 + 'isPartial' => 'bool', 29 + ), 30 + self::CONFIG_KEY_SCHEMA => array( 31 + 'sessionKey' => array( 32 + 'columns' => array('sessionKey'), 33 + 'unique' => true, 34 + ), 35 + 'key_identity' => array( 36 + 'columns' => array('userPHID', 'type'), 37 + ), 38 + 'key_expires' => array( 39 + 'columns' => array('sessionExpires'), 40 + ), 41 + ), 22 42 ) + parent::getConfiguration(); 23 43 } 24 44
+13 -2
src/applications/config/schema/PhabricatorConfigSchemaQuery.php
··· 269 269 PhabricatorConfigStorageSchema $expect = null, 270 270 PhabricatorConfigStorageSchema $actual = null) { 271 271 272 + $expect_is_key = ($expect instanceof PhabricatorConfigKeySchema); 273 + $actual_is_key = ($actual instanceof PhabricatorConfigKeySchema); 274 + 275 + if ($expect_is_key || $actual_is_key) { 276 + $missing_issue = PhabricatorConfigStorageSchema::ISSUE_MISSINGKEY; 277 + $surplus_issue = PhabricatorConfigStorageSchema::ISSUE_SURPLUSKEY; 278 + } else { 279 + $missing_issue = PhabricatorConfigStorageSchema::ISSUE_MISSING; 280 + $surplus_issue = PhabricatorConfigStorageSchema::ISSUE_SURPLUS; 281 + } 282 + 272 283 if (!$expect && !$actual) { 273 284 throw new Exception(pht('Can not compare two missing schemata!')); 274 285 } else if ($expect && !$actual) { 275 - $issues = array(PhabricatorConfigStorageSchema::ISSUE_MISSING); 286 + $issues = array($missing_issue); 276 287 } else if ($actual && !$expect) { 277 - $issues = array(PhabricatorConfigStorageSchema::ISSUE_SURPLUS); 288 + $issues = array($surplus_issue); 278 289 } else { 279 290 $issues = $actual->compareTo($expect); 280 291 }
+10
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 245 245 $charset = 'binary'; 246 246 $collation = 'binary'; 247 247 break; 248 + case 'bytes64': 249 + $column_type = 'char(64)'; 250 + $charset = 'binary'; 251 + $collation = 'binary'; 252 + break; 248 253 case 'bytes40': 249 254 $column_type = 'char(40)'; 250 255 $charset = 'binary'; ··· 275 280 break; 276 281 case 'text255': 277 282 $column_type = 'varchar(255)'; 283 + $charset = $this->getUTF8Charset(); 284 + $collation = $this->getUTF8Collation(); 285 + break; 286 + case 'text160': 287 + $column_type = 'varchar(160)'; 278 288 $charset = $this->getUTF8Charset(); 279 289 $collation = $this->getUTF8Collation(); 280 290 break;
+14 -2
src/applications/config/schema/PhabricatorConfigStorageSchema.php
··· 3 3 abstract class PhabricatorConfigStorageSchema extends Phobject { 4 4 5 5 const ISSUE_MISSING = 'missing'; 6 + const ISSUE_MISSINGKEY = 'missingkey'; 6 7 const ISSUE_SURPLUS = 'surplus'; 8 + const ISSUE_SURPLUSKEY = 'surpluskey'; 7 9 const ISSUE_CHARSET = 'charset'; 8 10 const ISSUE_COLLATION = 'collation'; 9 11 const ISSUE_COLUMNTYPE = 'columntype'; ··· 102 104 switch ($issue) { 103 105 case self::ISSUE_MISSING: 104 106 return pht('Missing'); 107 + case self::ISSUE_MISSINGKEY: 108 + return pht('Missing Key'); 105 109 case self::ISSUE_SURPLUS: 106 110 return pht('Surplus'); 111 + case self::ISSUE_SURPLUSKEY: 112 + return pht('Surplus Key'); 107 113 case self::ISSUE_CHARSET: 108 114 return pht('Better Character Set Available'); 109 115 case self::ISSUE_COLLATION: ··· 131 137 switch ($issue) { 132 138 case self::ISSUE_MISSING: 133 139 return pht('This schema is expected to exist, but does not.'); 140 + case self::ISSUE_MISSINGKEY: 141 + return pht('This key is expected to exist, but does not.'); 134 142 case self::ISSUE_SURPLUS: 135 143 return pht('This schema is not expected to exist.'); 144 + case self::ISSUE_SURPLUSKEY: 145 + return pht('This key is not expected to exist.'); 136 146 case self::ISSUE_CHARSET: 137 147 return pht('This schema can use a better character set.'); 138 148 case self::ISSUE_COLLATION: ··· 159 169 public static function getIssueStatus($issue) { 160 170 switch ($issue) { 161 171 case self::ISSUE_MISSING: 172 + case self::ISSUE_MISSINGKEY: 162 173 case self::ISSUE_SUBFAIL: 163 174 return self::STATUS_FAIL; 164 175 case self::ISSUE_SURPLUS: 165 - case self::ISSUE_COLUMNTYPE: 176 + case self::ISSUE_SURPLUSKEY: 166 177 case self::ISSUE_SUBWARN: 178 + case self::ISSUE_COLUMNTYPE: 167 179 case self::ISSUE_KEYCOLUMNS: 180 + case self::ISSUE_UNIQUE: 168 181 case self::ISSUE_NULLABLE: 169 - case self::ISSUE_UNIQUE: 170 182 return self::STATUS_WARN; 171 183 case self::ISSUE_SUBNOTE: 172 184 case self::ISSUE_CHARSET:
+25
src/applications/people/storage/PhabricatorExternalAccount.php
··· 39 39 self::CONFIG_SERIALIZATION => array( 40 40 'properties' => self::SERIALIZATION_JSON, 41 41 ), 42 + self::CONFIG_COLUMN_SCHEMA => array( 43 + 'userPHID' => 'phid?', 44 + 'accountType' => 'text16', 45 + 'accountDomain' => 'text64', 46 + 'accountSecret' => 'text?', 47 + 'accountID' => 'text160', 48 + 'displayName' => 'text255?', 49 + 'username' => 'text255?', 50 + 'realName' => 'text255?', 51 + 'email' => 'text255?', 52 + 'emailVerified' => 'bool', 53 + 'profileImagePHID' => 'phid?', 54 + 'accountURI' => 'text255?', 55 + ), 56 + self::CONFIG_KEY_SCHEMA => array( 57 + 'key_phid' => null, 58 + 'phid' => array( 59 + 'columns' => array('phid'), 60 + 'unique' => true, 61 + ), 62 + 'account_details' => array( 63 + 'columns' => array('accountType', 'accountDomain', 'accountID'), 64 + 'unique' => true, 65 + ), 66 + ), 42 67 ) + parent::getConfiguration(); 43 68 } 44 69
+38
src/applications/people/storage/PhabricatorUser.php
··· 113 113 public function getConfiguration() { 114 114 return array( 115 115 self::CONFIG_AUX_PHID => true, 116 + self::CONFIG_COLUMN_SCHEMA => array( 117 + 'userName' => 'text64', 118 + 'realName' => 'text128', 119 + 'sex' => 'text4?', 120 + 'translation' => 'text64?', 121 + 'passwordSalt' => 'text32?', 122 + 'passwordHash' => 'text128?', 123 + 'profileImagePHID' => 'phid?', 124 + 'consoleEnabled' => 'bool', 125 + 'consoleVisible' => 'bool', 126 + 'consoleTab' => 'text64', 127 + 'conduitCertificate' => 'text255', 128 + 'isSystemAgent' => 'bool', 129 + 'isDisabled' => 'bool', 130 + 'isAdmin' => 'bool', 131 + 'timezoneIdentifier' => 'text255', 132 + 'isEmailVerified' => 'uint32', 133 + 'isApproved' => 'uint32', 134 + 'accountSecret' => 'bytes64', 135 + 'isEnrolledInMultiFactor' => 'bool', 136 + ), 137 + self::CONFIG_KEY_SCHEMA => array( 138 + 'key_phid' => null, 139 + 'phid' => array( 140 + 'columns' => array('phid'), 141 + 'unique' => true, 142 + ), 143 + 'userName' => array( 144 + 'columns' => array('userName'), 145 + 'unique' => true, 146 + ), 147 + 'realName' => array( 148 + 'columns' => array('realName'), 149 + ), 150 + 'key_approved' => array( 151 + 'columns' => array('isApproved'), 152 + ), 153 + ), 116 154 ) + parent::getConfiguration(); 117 155 } 118 156
+20
src/applications/people/storage/PhabricatorUserEmail.php
··· 14 14 15 15 const MAX_ADDRESS_LENGTH = 128; 16 16 17 + public function getConfiguration() { 18 + return array( 19 + self::CONFIG_COLUMN_SCHEMA => array( 20 + 'address' => 'text128', 21 + 'isVerified' => 'bool', 22 + 'isPrimary' => 'bool', 23 + 'verificationCode' => 'text64?', 24 + ), 25 + self::CONFIG_KEY_SCHEMA => array( 26 + 'address' => array( 27 + 'columns' => array('address'), 28 + 'unique' => true, 29 + ), 30 + 'userPHID' => array( 31 + 'columns' => array('userPHID', 'isPrimary'), 32 + ), 33 + ), 34 + ) + parent::getConfiguration(); 35 + } 36 + 17 37 public function getVerificationURI() { 18 38 return '/emailverify/'.$this->getVerificationCode().'/'; 19 39 }
+26
src/applications/people/storage/PhabricatorUserLog.php
··· 129 129 'newValue' => self::SERIALIZATION_JSON, 130 130 'details' => self::SERIALIZATION_JSON, 131 131 ), 132 + self::CONFIG_COLUMN_SCHEMA => array( 133 + 'actorPHID' => 'phid?', 134 + 'action' => 'text64', 135 + 'remoteAddr' => 'text64', 136 + 'session' => 'bytes40?', 137 + ), 138 + self::CONFIG_KEY_SCHEMA => array( 139 + 'actorPHID' => array( 140 + 'columns' => array('actorPHID', 'dateCreated'), 141 + ), 142 + 'userPHID' => array( 143 + 'columns' => array('userPHID', 'dateCreated'), 144 + ), 145 + 'action' => array( 146 + 'columns' => array('action', 'dateCreated'), 147 + ), 148 + 'dateCreated' => array( 149 + 'columns' => array('dateCreated'), 150 + ), 151 + 'remoteAddr' => array( 152 + 'columns' => array('remoteAddr', 'dateCreated'), 153 + ), 154 + 'session' => array( 155 + 'columns' => array('session', 'dateCreated'), 156 + ), 157 + ), 132 158 ) + parent::getConfiguration(); 133 159 } 134 160
+16
src/applications/people/storage/PhabricatorUserProfile.php
··· 7 7 protected $blurb; 8 8 protected $profileImagePHID; 9 9 10 + public function getConfiguration() { 11 + return array( 12 + self::CONFIG_COLUMN_SCHEMA => array( 13 + 'title' => 'text255', 14 + 'blurb' => 'text', 15 + 'profileImagePHID' => 'phid?', 16 + ), 17 + self::CONFIG_KEY_SCHEMA => array( 18 + 'userPHID' => array( 19 + 'columns' => array('userPHID'), 20 + 'unique' => true, 21 + ), 22 + ), 23 + ) + parent::getConfiguration(); 24 + } 25 + 10 26 }
+38
src/applications/people/storage/PhabricatorUserSchemaSpec.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserSchemaSpec extends PhabricatorConfigSchemaSpec { 4 + 5 + public function buildSchemata() { 6 + $this->buildLiskSchemata('PhabricatorUserDAO'); 7 + 8 + $this->buildEdgeSchemata(new PhabricatorUser()); 9 + 10 + $this->buildTransactionSchema( 11 + new PhabricatorUserTransaction()); 12 + 13 + $this->buildCustomFieldSchemata( 14 + new PhabricatorUserConfiguredCustomFieldStorage(), 15 + array( 16 + new PhabricatorUserCustomFieldNumericIndex(), 17 + new PhabricatorUserCustomFieldStringIndex(), 18 + )); 19 + 20 + $this->buildRawSchema( 21 + id(new PhabricatorUser())->getApplicationName(), 22 + PhabricatorUser::NAMETOKEN_TABLE, 23 + array( 24 + 'token' => 'text255', 25 + 'userID' => 'id', 26 + ), 27 + array( 28 + 'token' => array( 29 + 'columns' => array('token'), 30 + ), 31 + 'userID' => array( 32 + 'columns' => array('userID'), 33 + ), 34 + )); 35 + 36 + } 37 + 38 + }
+6
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 46 46 'preferences' => self::SERIALIZATION_JSON, 47 47 ), 48 48 self::CONFIG_TIMESTAMPS => false, 49 + self::CONFIG_KEY_SCHEMA => array( 50 + 'userPHID' => array( 51 + 'columns' => array('userPHID'), 52 + 'unique' => true, 53 + ), 54 + ), 49 55 ) + parent::getConfiguration(); 50 56 } 51 57
+21
src/applications/settings/storage/PhabricatorUserSSHKey.php
··· 9 9 protected $keyHash; 10 10 protected $keyComment; 11 11 12 + public function getConfiguration() { 13 + return array( 14 + self::CONFIG_COLUMN_SCHEMA => array( 15 + 'name' => 'text255', 16 + 'keyType' => 'text255', 17 + 'keyBody' => 'text', 18 + 'keyHash' => 'bytes32', 19 + 'keyComment' => 'text255?', 20 + ), 21 + self::CONFIG_KEY_SCHEMA => array( 22 + 'userPHID' => array( 23 + 'columns' => array('userPHID'), 24 + ), 25 + 'keyHash' => array( 26 + 'columns' => array('keyHash'), 27 + 'unique' => true, 28 + ), 29 + ), 30 + ) + parent::getConfiguration(); 31 + } 32 + 12 33 public function getEntireKey() { 13 34 $parts = array( 14 35 $this->getKeyType(),
+22 -2
src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
··· 8 8 private $localTime; 9 9 10 10 public function getConfiguration() { 11 - return array( 11 + $parent = parent::getConfiguration(); 12 + 13 + $config = array( 12 14 self::CONFIG_IDS => self::IDS_COUNTER, 13 15 self::CONFIG_TIMESTAMPS => false, 14 16 self::CONFIG_KEY_SCHEMA => array( 15 17 'dataID' => array( 16 18 'columns' => array('dataID'), 19 + 'unique' => true, 20 + ), 21 + 'taskClass' => array( 22 + 'columns' => array('taskClass'), 23 + ), 24 + 'leaseExpires' => array( 25 + 'columns' => array('leaseExpires'), 26 + ), 27 + 'leaseOwner' => array( 28 + 'columns' => array('leaseOwner(16)'), 29 + ), 30 + 'key_failuretime' => array( 31 + 'columns' => array('failureTime'), 32 + ), 33 + 'leaseOwner_2' => array( 34 + 'columns' => array('leaseOwner', 'priority', 'id'), 17 35 ), 18 36 ), 19 - ) + parent::getConfiguration(); 37 + ); 38 + 39 + return $config + $parent; 20 40 } 21 41 22 42 public function setServerTime($server_time) {
+11
src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
··· 11 11 12 12 public function getConfiguration() { 13 13 $config = parent::getConfiguration(); 14 + 14 15 $config[self::CONFIG_COLUMN_SCHEMA] = array( 15 16 'result' => 'uint32', 16 17 'duration' => 'uint64', 17 18 ) + $config[self::CONFIG_COLUMN_SCHEMA]; 19 + 20 + $config[self::CONFIG_KEY_SCHEMA] = array( 21 + 'dateCreated' => array( 22 + 'columns' => array('dateCreated'), 23 + ), 24 + 'leaseOwner' => array( 25 + 'columns' => array('leaseOwner', 'priority', 'id'), 26 + ), 27 + ); 28 + 18 29 return $config; 19 30 } 20 31