diff --git a/resources/sql/autopatches/20140926.schema.03.dropldapinfo.sql b/resources/sql/autopatches/20140926.schema.03.dropldapinfo.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20140926.schema.03.dropldapinfo.sql @@ -0,0 +1 @@ +DROP TABLE {$NAMESPACE}_user.user_ldapinfo; diff --git a/resources/sql/autopatches/20140926.schema.04.dropoauthinfo.sql b/resources/sql/autopatches/20140926.schema.04.dropoauthinfo.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20140926.schema.04.dropoauthinfo.sql @@ -0,0 +1 @@ +DROP TABLE {$NAMESPACE}_user.user_oauthinfo; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2419,6 +2419,7 @@ 'PhabricatorUserRealNameField' => 'applications/people/customfield/PhabricatorUserRealNameField.php', 'PhabricatorUserRolesField' => 'applications/people/customfield/PhabricatorUserRolesField.php', 'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php', + 'PhabricatorUserSchemaSpec' => 'applications/people/storage/PhabricatorUserSchemaSpec.php', 'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php', 'PhabricatorUserSinceField' => 'applications/people/customfield/PhabricatorUserSinceField.php', 'PhabricatorUserStatusField' => 'applications/people/customfield/PhabricatorUserStatusField.php', @@ -5417,6 +5418,7 @@ 'PhabricatorUserRealNameField' => 'PhabricatorUserCustomField', 'PhabricatorUserRolesField' => 'PhabricatorUserCustomField', 'PhabricatorUserSSHKey' => 'PhabricatorUserDAO', + 'PhabricatorUserSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorUserSinceField' => 'PhabricatorUserCustomField', 'PhabricatorUserStatusField' => 'PhabricatorUserCustomField', diff --git a/src/applications/auth/storage/PhabricatorAuthSession.php b/src/applications/auth/storage/PhabricatorAuthSession.php --- a/src/applications/auth/storage/PhabricatorAuthSession.php +++ b/src/applications/auth/storage/PhabricatorAuthSession.php @@ -19,6 +19,26 @@ public function getConfiguration() { return array( self::CONFIG_TIMESTAMPS => false, + self::CONFIG_COLUMN_SCHEMA => array( + 'type' => 'text32', + 'sessionKey' => 'bytes40', + 'sessionStart' => 'epoch', + 'sessionExpires' => 'epoch', + 'highSecurityUntil' => 'epoch?', + 'isPartial' => 'bool', + ), + self::CONFIG_KEY_SCHEMA => array( + 'sessionKey' => array( + 'columns' => array('sessionKey'), + 'unique' => true, + ), + 'key_identity' => array( + 'columns' => array('userPHID', 'type'), + ), + 'key_expires' => array( + 'columns' => array('sessionExpires'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php --- a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php @@ -269,12 +269,23 @@ PhabricatorConfigStorageSchema $expect = null, PhabricatorConfigStorageSchema $actual = null) { + $expect_is_key = ($expect instanceof PhabricatorConfigKeySchema); + $actual_is_key = ($actual instanceof PhabricatorConfigKeySchema); + + if ($expect_is_key || $actual_is_key) { + $missing_issue = PhabricatorConfigStorageSchema::ISSUE_MISSINGKEY; + $surplus_issue = PhabricatorConfigStorageSchema::ISSUE_SURPLUSKEY; + } else { + $missing_issue = PhabricatorConfigStorageSchema::ISSUE_MISSING; + $surplus_issue = PhabricatorConfigStorageSchema::ISSUE_SURPLUS; + } + if (!$expect && !$actual) { throw new Exception(pht('Can not compare two missing schemata!')); } else if ($expect && !$actual) { - $issues = array(PhabricatorConfigStorageSchema::ISSUE_MISSING); + $issues = array($missing_issue); } else if ($actual && !$expect) { - $issues = array(PhabricatorConfigStorageSchema::ISSUE_SURPLUS); + $issues = array($surplus_issue); } else { $issues = $actual->compareTo($expect); } diff --git a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php --- a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php @@ -245,6 +245,11 @@ $charset = 'binary'; $collation = 'binary'; break; + case 'bytes64': + $column_type = 'char(64)'; + $charset = 'binary'; + $collation = 'binary'; + break; case 'bytes40': $column_type = 'char(40)'; $charset = 'binary'; @@ -278,6 +283,11 @@ $charset = $this->getUTF8Charset(); $collation = $this->getUTF8Collation(); break; + case 'text160': + $column_type = 'varchar(160)'; + $charset = $this->getUTF8Charset(); + $collation = $this->getUTF8Collation(); + break; case 'text128': $column_type = 'varchar(128)'; $charset = $this->getUTF8Charset(); diff --git a/src/applications/config/schema/PhabricatorConfigStorageSchema.php b/src/applications/config/schema/PhabricatorConfigStorageSchema.php --- a/src/applications/config/schema/PhabricatorConfigStorageSchema.php +++ b/src/applications/config/schema/PhabricatorConfigStorageSchema.php @@ -3,7 +3,9 @@ abstract class PhabricatorConfigStorageSchema extends Phobject { const ISSUE_MISSING = 'missing'; + const ISSUE_MISSINGKEY = 'missingkey'; const ISSUE_SURPLUS = 'surplus'; + const ISSUE_SURPLUSKEY = 'surpluskey'; const ISSUE_CHARSET = 'charset'; const ISSUE_COLLATION = 'collation'; const ISSUE_COLUMNTYPE = 'columntype'; @@ -102,8 +104,12 @@ switch ($issue) { case self::ISSUE_MISSING: return pht('Missing'); + case self::ISSUE_MISSINGKEY: + return pht('Missing Key'); case self::ISSUE_SURPLUS: return pht('Surplus'); + case self::ISSUE_SURPLUSKEY: + return pht('Surplus Key'); case self::ISSUE_CHARSET: return pht('Better Character Set Available'); case self::ISSUE_COLLATION: @@ -131,8 +137,12 @@ switch ($issue) { case self::ISSUE_MISSING: return pht('This schema is expected to exist, but does not.'); + case self::ISSUE_MISSINGKEY: + return pht('This key is expected to exist, but does not.'); case self::ISSUE_SURPLUS: return pht('This schema is not expected to exist.'); + case self::ISSUE_SURPLUSKEY: + return pht('This key is not expected to exist.'); case self::ISSUE_CHARSET: return pht('This schema can use a better character set.'); case self::ISSUE_COLLATION: @@ -159,14 +169,16 @@ public static function getIssueStatus($issue) { switch ($issue) { case self::ISSUE_MISSING: + case self::ISSUE_MISSINGKEY: case self::ISSUE_SUBFAIL: return self::STATUS_FAIL; case self::ISSUE_SURPLUS: - case self::ISSUE_COLUMNTYPE: + case self::ISSUE_SURPLUSKEY: case self::ISSUE_SUBWARN: + case self::ISSUE_COLUMNTYPE: case self::ISSUE_KEYCOLUMNS: - case self::ISSUE_NULLABLE: case self::ISSUE_UNIQUE: + case self::ISSUE_NULLABLE: return self::STATUS_WARN; case self::ISSUE_SUBNOTE: case self::ISSUE_CHARSET: diff --git a/src/applications/people/storage/PhabricatorExternalAccount.php b/src/applications/people/storage/PhabricatorExternalAccount.php --- a/src/applications/people/storage/PhabricatorExternalAccount.php +++ b/src/applications/people/storage/PhabricatorExternalAccount.php @@ -39,6 +39,31 @@ self::CONFIG_SERIALIZATION => array( 'properties' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'userPHID' => 'phid?', + 'accountType' => 'text16', + 'accountDomain' => 'text64', + 'accountSecret' => 'text?', + 'accountID' => 'text160', + 'displayName' => 'text255?', + 'username' => 'text255?', + 'realName' => 'text255?', + 'email' => 'text255?', + 'emailVerified' => 'bool', + 'profileImagePHID' => 'phid?', + 'accountURI' => 'text255?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'account_details' => array( + 'columns' => array('accountType', 'accountDomain', 'accountID'), + 'unique' => true, + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -113,6 +113,44 @@ public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'userName' => 'text64', + 'realName' => 'text128', + 'sex' => 'text4?', + 'translation' => 'text64?', + 'passwordSalt' => 'text32?', + 'passwordHash' => 'text128?', + 'profileImagePHID' => 'phid?', + 'consoleEnabled' => 'bool', + 'consoleVisible' => 'bool', + 'consoleTab' => 'text64', + 'conduitCertificate' => 'text255', + 'isSystemAgent' => 'bool', + 'isDisabled' => 'bool', + 'isAdmin' => 'bool', + 'timezoneIdentifier' => 'text255', + 'isEmailVerified' => 'uint32', + 'isApproved' => 'uint32', + 'accountSecret' => 'bytes64', + 'isEnrolledInMultiFactor' => 'bool', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'userName' => array( + 'columns' => array('userName'), + 'unique' => true, + ), + 'realName' => array( + 'columns' => array('realName'), + ), + 'key_approved' => array( + 'columns' => array('isApproved'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/people/storage/PhabricatorUserEmail.php b/src/applications/people/storage/PhabricatorUserEmail.php --- a/src/applications/people/storage/PhabricatorUserEmail.php +++ b/src/applications/people/storage/PhabricatorUserEmail.php @@ -14,6 +14,26 @@ const MAX_ADDRESS_LENGTH = 128; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'address' => 'text128', + 'isVerified' => 'bool', + 'isPrimary' => 'bool', + 'verificationCode' => 'text64?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'address' => array( + 'columns' => array('address'), + 'unique' => true, + ), + 'userPHID' => array( + 'columns' => array('userPHID', 'isPrimary'), + ), + ), + ) + parent::getConfiguration(); + } + public function getVerificationURI() { return '/emailverify/'.$this->getVerificationCode().'/'; } diff --git a/src/applications/people/storage/PhabricatorUserLog.php b/src/applications/people/storage/PhabricatorUserLog.php --- a/src/applications/people/storage/PhabricatorUserLog.php +++ b/src/applications/people/storage/PhabricatorUserLog.php @@ -129,6 +129,32 @@ 'newValue' => self::SERIALIZATION_JSON, 'details' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'actorPHID' => 'phid?', + 'action' => 'text64', + 'remoteAddr' => 'text64', + 'session' => 'bytes40?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'actorPHID' => array( + 'columns' => array('actorPHID', 'dateCreated'), + ), + 'userPHID' => array( + 'columns' => array('userPHID', 'dateCreated'), + ), + 'action' => array( + 'columns' => array('action', 'dateCreated'), + ), + 'dateCreated' => array( + 'columns' => array('dateCreated'), + ), + 'remoteAddr' => array( + 'columns' => array('remoteAddr', 'dateCreated'), + ), + 'session' => array( + 'columns' => array('session', 'dateCreated'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/people/storage/PhabricatorUserProfile.php b/src/applications/people/storage/PhabricatorUserProfile.php --- a/src/applications/people/storage/PhabricatorUserProfile.php +++ b/src/applications/people/storage/PhabricatorUserProfile.php @@ -7,4 +7,20 @@ protected $blurb; protected $profileImagePHID; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'title' => 'text255', + 'blurb' => 'text', + 'profileImagePHID' => 'phid?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'userPHID' => array( + 'columns' => array('userPHID'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + } diff --git a/src/applications/people/storage/PhabricatorUserSchemaSpec.php b/src/applications/people/storage/PhabricatorUserSchemaSpec.php new file mode 100644 --- /dev/null +++ b/src/applications/people/storage/PhabricatorUserSchemaSpec.php @@ -0,0 +1,38 @@ +buildLiskSchemata('PhabricatorUserDAO'); + + $this->buildEdgeSchemata(new PhabricatorUser()); + + $this->buildTransactionSchema( + new PhabricatorUserTransaction()); + + $this->buildCustomFieldSchemata( + new PhabricatorUserConfiguredCustomFieldStorage(), + array( + new PhabricatorUserCustomFieldNumericIndex(), + new PhabricatorUserCustomFieldStringIndex(), + )); + + $this->buildRawSchema( + id(new PhabricatorUser())->getApplicationName(), + PhabricatorUser::NAMETOKEN_TABLE, + array( + 'token' => 'text255', + 'userID' => 'id', + ), + array( + 'token' => array( + 'columns' => array('token'), + ), + 'userID' => array( + 'columns' => array('userID'), + ), + )); + + } + +} diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php --- a/src/applications/settings/storage/PhabricatorUserPreferences.php +++ b/src/applications/settings/storage/PhabricatorUserPreferences.php @@ -46,6 +46,12 @@ 'preferences' => self::SERIALIZATION_JSON, ), self::CONFIG_TIMESTAMPS => false, + self::CONFIG_KEY_SCHEMA => array( + 'userPHID' => array( + 'columns' => array('userPHID'), + 'unique' => true, + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/settings/storage/PhabricatorUserSSHKey.php b/src/applications/settings/storage/PhabricatorUserSSHKey.php --- a/src/applications/settings/storage/PhabricatorUserSSHKey.php +++ b/src/applications/settings/storage/PhabricatorUserSSHKey.php @@ -9,6 +9,27 @@ protected $keyHash; protected $keyComment; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + 'keyType' => 'text255', + 'keyBody' => 'text', + 'keyHash' => 'bytes32', + 'keyComment' => 'text255?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'userPHID' => array( + 'columns' => array('userPHID'), + ), + 'keyHash' => array( + 'columns' => array('keyHash'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + public function getEntireKey() { $parts = array( $this->getKeyType(), diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php --- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php +++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php @@ -8,15 +8,35 @@ private $localTime; public function getConfiguration() { - return array( + $parent = parent::getConfiguration(); + + $config = array( self::CONFIG_IDS => self::IDS_COUNTER, self::CONFIG_TIMESTAMPS => false, self::CONFIG_KEY_SCHEMA => array( 'dataID' => array( 'columns' => array('dataID'), + 'unique' => true, + ), + 'taskClass' => array( + 'columns' => array('taskClass'), + ), + 'leaseExpires' => array( + 'columns' => array('leaseExpires'), + ), + 'leaseOwner' => array( + 'columns' => array('leaseOwner(16)'), + ), + 'key_failuretime' => array( + 'columns' => array('failureTime'), + ), + 'leaseOwner_2' => array( + 'columns' => array('leaseOwner', 'priority', 'id'), ), ), - ) + parent::getConfiguration(); + ); + + return $config + $parent; } public function setServerTime($server_time) { diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php --- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php +++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php @@ -11,10 +11,21 @@ public function getConfiguration() { $config = parent::getConfiguration(); + $config[self::CONFIG_COLUMN_SCHEMA] = array( 'result' => 'uint32', 'duration' => 'uint64', ) + $config[self::CONFIG_COLUMN_SCHEMA]; + + $config[self::CONFIG_KEY_SCHEMA] = array( + 'dateCreated' => array( + 'columns' => array('dateCreated'), + ), + 'leaseOwner' => array( + 'columns' => array('leaseOwner', 'priority', 'id'), + ), + ); + return $config; }