From d6639b68d5a32a579251fb1d87a1c3a44f40ad4a Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 24 Sep 2014 13:50:00 -0700 Subject: [PATCH] Generate expected schemata for MetaMTA, Nuance, MetaData, OAuthServer Summary: Ref T1191. Handful of minor things here (T6150, T6149, T6148, T6147, T6146) but nothing very noteworthy. Test Plan: Viewed web UI, saw fewer errors. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10527 --- src/__phutil_library_map__.php | 8 ++++++ .../schema/PhabricatorConfigSchemaSpec.php | 5 ++++ .../storage/PhabricatorMetaMTAMailingList.php | 20 ++++++++++++++ .../storage/PhabricatorMetaMTAMail.php | 16 +++++++++++ .../PhabricatorMetaMTAReceivedMail.php | 21 +++++++++++++++ .../storage/PhabricatorMetaMTASchemaSpec.php | 14 ++++++++++ .../nuance/storage/NuanceItem.php | 19 +++++++++++++ .../nuance/storage/NuanceQueue.php | 4 +++ .../nuance/storage/NuanceQueueItem.php | 17 ++++++++++++ .../nuance/storage/NuanceSchemaSpec.php | 27 +++++++++++++++++++ .../nuance/storage/NuanceSource.php | 10 +++++++ .../PhabricatorOAuthClientAuthorization.php | 14 ++++++++++ .../storage/PhabricatorOAuthSchemaSpec.php | 10 +++++++ .../PhabricatorOAuthServerAccessToken.php | 15 +++++++++++ ...habricatorOAuthServerAuthorizationCode.php | 17 ++++++++++++ .../storage/PhabricatorOAuthServerClient.php | 15 +++++++++++ .../sms/storage/PhabricatorSMS.php | 19 +++++++++++++ .../schema/PhabricatorStorageSchemaSpec.php | 22 +++++++++++++++ 18 files changed, 273 insertions(+) create mode 100644 src/applications/metamta/storage/PhabricatorMetaMTASchemaSpec.php create mode 100644 src/applications/nuance/storage/NuanceSchemaSpec.php create mode 100644 src/applications/oauthserver/storage/PhabricatorOAuthSchemaSpec.php create mode 100644 src/infrastructure/storage/schema/PhabricatorStorageSchemaSpec.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index fc4f8c1b35..0b57d6b0aa 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -992,6 +992,7 @@ phutil_register_library_map(array( 'NuanceRequestorTransactionComment' => 'applications/nuance/storage/NuanceRequestorTransactionComment.php', 'NuanceRequestorTransactionQuery' => 'applications/nuance/query/NuanceRequestorTransactionQuery.php', 'NuanceRequestorViewController' => 'applications/nuance/controller/NuanceRequestorViewController.php', + 'NuanceSchemaSpec' => 'applications/nuance/storage/NuanceSchemaSpec.php', 'NuanceSource' => 'applications/nuance/storage/NuanceSource.php', 'NuanceSourceDefaultEditCapability' => 'applications/nuance/capability/NuanceSourceDefaultEditCapability.php', 'NuanceSourceDefaultViewCapability' => 'applications/nuance/capability/NuanceSourceDefaultViewCapability.php', @@ -1808,6 +1809,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAReceivedMail' => 'applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php', 'PhabricatorMetaMTAReceivedMailProcessingException' => 'applications/metamta/exception/PhabricatorMetaMTAReceivedMailProcessingException.php', 'PhabricatorMetaMTAReceivedMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php', + 'PhabricatorMetaMTASchemaSpec' => 'applications/metamta/storage/PhabricatorMetaMTASchemaSpec.php', 'PhabricatorMetaMTASendGridReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php', 'PhabricatorMetaMTAWorker' => 'applications/metamta/PhabricatorMetaMTAWorker.php', 'PhabricatorMultiColumnExample' => 'applications/uiexample/examples/PhabricatorMultiColumnExample.php', @@ -1844,6 +1846,7 @@ phutil_register_library_map(array( 'PhabricatorOAuthClientListController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php', 'PhabricatorOAuthClientViewController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php', 'PhabricatorOAuthResponse' => 'applications/oauthserver/PhabricatorOAuthResponse.php', + 'PhabricatorOAuthSchemaSpec' => 'applications/oauthserver/storage/PhabricatorOAuthSchemaSpec.php', 'PhabricatorOAuthServer' => 'applications/oauthserver/PhabricatorOAuthServer.php', 'PhabricatorOAuthServerAccessToken' => 'applications/oauthserver/storage/PhabricatorOAuthServerAccessToken.php', 'PhabricatorOAuthServerApplication' => 'applications/oauthserver/application/PhabricatorOAuthServerApplication.php', @@ -2305,6 +2308,7 @@ phutil_register_library_map(array( 'PhabricatorStorageManagementUpgradeWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php', 'PhabricatorStorageManagementWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php', 'PhabricatorStoragePatch' => 'infrastructure/storage/management/PhabricatorStoragePatch.php', + 'PhabricatorStorageSchemaSpec' => 'infrastructure/storage/schema/PhabricatorStorageSchemaSpec.php', 'PhabricatorSubscribableInterface' => 'applications/subscriptions/interface/PhabricatorSubscribableInterface.php', 'PhabricatorSubscribersQuery' => 'applications/subscriptions/query/PhabricatorSubscribersQuery.php', 'PhabricatorSubscriptionsApplication' => 'applications/subscriptions/application/PhabricatorSubscriptionsApplication.php', @@ -3892,6 +3896,7 @@ phutil_register_library_map(array( 'NuanceRequestorTransactionComment' => 'PhabricatorApplicationTransactionComment', 'NuanceRequestorTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'NuanceRequestorViewController' => 'NuanceController', + 'NuanceSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'NuanceSource' => array( 'NuanceDAO', 'PhabricatorPolicyInterface', @@ -4738,6 +4743,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAReceivedMail' => 'PhabricatorMetaMTADAO', 'PhabricatorMetaMTAReceivedMailProcessingException' => 'Exception', 'PhabricatorMetaMTAReceivedMailTestCase' => 'PhabricatorTestCase', + 'PhabricatorMetaMTASchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PhabricatorMetaMTASendGridReceiveController' => 'PhabricatorMetaMTAController', 'PhabricatorMetaMTAWorker' => 'PhabricatorWorker', 'PhabricatorMultiColumnExample' => 'PhabricatorUIExample', @@ -4778,6 +4784,7 @@ phutil_register_library_map(array( 'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthResponse' => 'AphrontResponse', + 'PhabricatorOAuthSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PhabricatorOAuthServerAccessToken' => 'PhabricatorOAuthServerDAO', 'PhabricatorOAuthServerApplication' => 'PhabricatorApplication', 'PhabricatorOAuthServerAuthController' => 'PhabricatorAuthController', @@ -5283,6 +5290,7 @@ phutil_register_library_map(array( 'PhabricatorStorageManagementStatusWorkflow' => 'PhabricatorStorageManagementWorkflow', 'PhabricatorStorageManagementUpgradeWorkflow' => 'PhabricatorStorageManagementWorkflow', 'PhabricatorStorageManagementWorkflow' => 'PhabricatorManagementWorkflow', + 'PhabricatorStorageSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PhabricatorSubscribersQuery' => 'PhabricatorQuery', 'PhabricatorSubscriptionsApplication' => 'PhabricatorApplication', 'PhabricatorSubscriptionsEditController' => 'PhabricatorController', diff --git a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php index eda715639d..bd4eb3075e 100644 --- a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php @@ -271,6 +271,11 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject { $charset = $this->getUTF8Charset(); $collation = $this->getUTF8Collation(); break; + case 'text40': + $column_type = 'varchar(40)'; + $charset = $this->getUTF8Charset(); + $collation = $this->getUTF8Collation(); + break; case 'text32': $column_type = 'varchar(32)'; $charset = $this->getUTF8Charset(); diff --git a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php index 794560e723..b2607e4848 100644 --- a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php +++ b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php @@ -17,6 +17,26 @@ final class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + 'email' => 'text255', + 'uri' => 'text255?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'email' => array( + 'columns' => array('email'), + 'unique' => true, + ), + 'name' => array( + 'columns' => array('name'), + 'unique' => true, + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index 9ac771ea23..d7882231ec 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -32,6 +32,22 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { self::CONFIG_SERIALIZATION => array( 'parameters' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'status' => 'text255', + 'message' => 'text', + 'relatedPHID' => 'phid?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'status' => array( + 'columns' => array('status'), + ), + 'relatedPHID' => array( + 'columns' => array('relatedPHID'), + ), + 'key_created' => array( + 'columns' => array('dateCreated'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php index 742b4e1ee4..b3828fce24 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php @@ -19,6 +19,27 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { 'bodies' => self::SERIALIZATION_JSON, 'attachments' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'relatedPHID' => 'phid?', + 'authorPHID' => 'phid?', + 'message' => 'text?', + 'messageIDHash' => 'bytes12', + 'status' => 'text32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'relatedPHID' => array( + 'columns' => array('relatedPHID'), + ), + 'authorPHID' => array( + 'columns' => array('authorPHID'), + ), + 'key_messageIDHash' => array( + 'columns' => array('messageIDHash'), + ), + 'key_created' => array( + 'columns' => array('dateCreated'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/metamta/storage/PhabricatorMetaMTASchemaSpec.php b/src/applications/metamta/storage/PhabricatorMetaMTASchemaSpec.php new file mode 100644 index 0000000000..4754a74c48 --- /dev/null +++ b/src/applications/metamta/storage/PhabricatorMetaMTASchemaSpec.php @@ -0,0 +1,14 @@ +buildLiskSchemata('PhabricatorMetaMTADAO'); + $this->buildLiskSchemata('PhabricatorSMSDAO'); + + $this->buildEdgeSchemata( + new PhabricatorMetaMTAMail()); + } + +} diff --git a/src/applications/nuance/storage/NuanceItem.php b/src/applications/nuance/storage/NuanceItem.php index 5f6193d1b0..fe02f7679a 100644 --- a/src/applications/nuance/storage/NuanceItem.php +++ b/src/applications/nuance/storage/NuanceItem.php @@ -22,12 +22,31 @@ final class NuanceItem ->setDateNuanced(time()) ->setStatus(NuanceItem::STATUS_OPEN); } + public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'data' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'ownerPHID' => 'phid?', + 'sourceLabel' => 'text255?', + 'status' => 'uint32', + 'mailKey' => 'bytes20', + 'dateNuanced' => 'epoch', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_source' => array( + 'columns' => array('sourcePHID', 'status', 'dateNuanced'), + ), + 'key_owner' => array( + 'columns' => array('ownerPHID', 'status', 'dateNuanced'), + ), + 'key_contacter' => array( + 'columns' => array('requestorPHID', 'status', 'dateNuanced'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/nuance/storage/NuanceQueue.php b/src/applications/nuance/storage/NuanceQueue.php index 5871df8504..4a172a9401 100644 --- a/src/applications/nuance/storage/NuanceQueue.php +++ b/src/applications/nuance/storage/NuanceQueue.php @@ -12,6 +12,10 @@ final class NuanceQueue public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255?', + 'mailKey' => 'bytes20', + ), ) + parent::getConfiguration(); } diff --git a/src/applications/nuance/storage/NuanceQueueItem.php b/src/applications/nuance/storage/NuanceQueueItem.php index 92bbb51056..3fbaecd099 100644 --- a/src/applications/nuance/storage/NuanceQueueItem.php +++ b/src/applications/nuance/storage/NuanceQueueItem.php @@ -8,5 +8,22 @@ final class NuanceQueueItem protected $itemStatus; protected $itemDateNuanced; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'itemStatus' => 'uint32', + 'itemDateNuanced' => 'epoch', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_one_per_queue' => array( + 'columns' => array('itemPHID', 'queuePHID'), + 'unique' => true, + ), + 'key_queue' => array( + 'columns' => array('queuePHID', 'itemStatus', 'itemDateNuanced'), + ), + ), + ) + parent::getConfiguration(); + } } diff --git a/src/applications/nuance/storage/NuanceSchemaSpec.php b/src/applications/nuance/storage/NuanceSchemaSpec.php new file mode 100644 index 0000000000..993dfe63f6 --- /dev/null +++ b/src/applications/nuance/storage/NuanceSchemaSpec.php @@ -0,0 +1,27 @@ +buildLiskSchemata('NuanceDAO'); + $this->buildEdgeSchemata(new NuanceItem()); + + $this->buildTransactionSchema( + new NuanceItemTransaction(), + new NuanceItemTransactionComment()); + + $this->buildTransactionSchema( + new NuanceQueueTransaction(), + new NuanceQueueTransactionComment()); + + $this->buildTransactionSchema( + new NuanceRequestorTransaction(), + new NuanceRequestorTransactionComment()); + + $this->buildTransactionSchema( + new NuanceSourceTransaction(), + new NuanceSourceTransactionComment()); + } + +} diff --git a/src/applications/nuance/storage/NuanceSource.php b/src/applications/nuance/storage/NuanceSource.php index e6fc9da86b..025a60dd89 100644 --- a/src/applications/nuance/storage/NuanceSource.php +++ b/src/applications/nuance/storage/NuanceSource.php @@ -16,6 +16,16 @@ final class NuanceSource extends NuanceDAO self::CONFIG_SERIALIZATION => array( 'data' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255?', + 'type' => 'text32', + 'mailKey' => 'bytes20', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_type' => array( + 'columns' => array('type', 'dateModified'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php b/src/applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php index c29c06eda2..505df7b2d7 100644 --- a/src/applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php @@ -23,6 +23,20 @@ final class PhabricatorOAuthClientAuthorization self::CONFIG_SERIALIZATION => array( 'scope' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'scope' => 'text', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'userPHID' => array( + 'columns' => array('userPHID', 'clientPHID'), + 'unique' => true, + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthSchemaSpec.php b/src/applications/oauthserver/storage/PhabricatorOAuthSchemaSpec.php new file mode 100644 index 0000000000..e7c8c002f1 --- /dev/null +++ b/src/applications/oauthserver/storage/PhabricatorOAuthSchemaSpec.php @@ -0,0 +1,10 @@ +buildLiskSchemata('PhabricatorOAuthServerDAO'); + } + +} diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerAccessToken.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerAccessToken.php index fd2e2d1080..1deadaa92b 100644 --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerAccessToken.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerAccessToken.php @@ -7,4 +7,19 @@ final class PhabricatorOAuthServerAccessToken protected $token; protected $userPHID; protected $clientPHID; + + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'token' => 'text32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'token' => array( + 'columns' => array('token'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerAuthorizationCode.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerAuthorizationCode.php index bbc39d2bc4..32212d987d 100644 --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerAuthorizationCode.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerAuthorizationCode.php @@ -9,4 +9,21 @@ final class PhabricatorOAuthServerAuthorizationCode protected $clientSecret; protected $userPHID; protected $redirectURI; + + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'code' => 'text32', + 'clientSecret' => 'text32', + 'redirectURI' => 'text255', + ), + self::CONFIG_KEY_SCHEMA => array( + 'code' => array( + 'columns' => array('code'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php index 1483ca5ce7..1316e5f017 100644 --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php @@ -30,6 +30,21 @@ final class PhabricatorOAuthServerClient public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + 'secret' => 'text32', + 'redirectURI' => 'text255', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'creatorPHID' => array( + 'columns' => array('creatorPHID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/infrastructure/sms/storage/PhabricatorSMS.php b/src/infrastructure/sms/storage/PhabricatorSMS.php index e880fad01d..eb03d890de 100644 --- a/src/infrastructure/sms/storage/PhabricatorSMS.php +++ b/src/infrastructure/sms/storage/PhabricatorSMS.php @@ -43,6 +43,25 @@ final class PhabricatorSMS ->setProviderSMSID(Filesystem::readRandomCharacters(40)); } + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'providerShortName' => 'text16', + 'providerSMSID' => 'text40', + 'toNumber' => 'text20', + 'fromNumber' => 'text20?', + 'body' => 'text', + 'sendStatus' => 'text16?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_provider' => array( + 'columns' => array('providerSMSID', 'providerShortName'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + public function getTableName() { // Slightly non-standard, but otherwise this class needs "MetaMTA" in its // name. :/ diff --git a/src/infrastructure/storage/schema/PhabricatorStorageSchemaSpec.php b/src/infrastructure/storage/schema/PhabricatorStorageSchemaSpec.php new file mode 100644 index 0000000000..39a1f1c2d9 --- /dev/null +++ b/src/infrastructure/storage/schema/PhabricatorStorageSchemaSpec.php @@ -0,0 +1,22 @@ +buildRawSchema( + 'meta_data', + 'patch_status', + array( + 'patch' => 'text255', + 'applied' => 'uint32', + ), + array( + 'PRIMARY' => array( + 'columns' => array('patch'), + 'unique' => true, + ), + )); + } + +}