From e7b590a1cf0de68e8b6ff6ffd2e90efdf70f85e3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Oct 2014 07:40:36 -0700 Subject: [PATCH] Generate expected schemata for Harbormaster Summary: Ref T1191. Nothing too notable here: - Allow a Lisk object to specify that there's no expectation that a table exists. We have one Harbormaster object and one Token object like this. - Removed BuildPlanTransactionComment because it's currently unused. Test Plan: - Saw ~200 fewer warnings; just ~800 left. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10583 --- src/__phutil_library_map__.php | 4 +- .../schema/PhabricatorConfigSchemaSpec.php | 3 ++ .../storage/HarbormasterBuildCommand.php | 13 ++++++ .../storage/HarbormasterBuildMessage.php | 14 ++++++ .../storage/HarbormasterBuildable.php | 16 +++++++ .../storage/HarbormasterObject.php | 4 +- .../storage/HarbormasterSchemaSpec.php | 45 +++++++++++++++++++ .../storage/HarbormasterScratchTable.php | 14 ++++++ .../storage/build/HarbormasterBuild.php | 15 +++++++ .../build/HarbormasterBuildArtifact.php | 14 ++++++ .../storage/build/HarbormasterBuildItem.php | 1 + .../storage/build/HarbormasterBuildLog.php | 11 +++++ .../storage/build/HarbormasterBuildTarget.php | 15 ++++++- .../configuration/HarbormasterBuildPlan.php | 9 ++++ .../HarbormasterBuildPlanTransaction.php | 4 -- ...arbormasterBuildPlanTransactionComment.php | 10 ----- .../configuration/HarbormasterBuildStep.php | 13 +++++- .../tokens/storage/PhabricatorToken.php | 1 + src/infrastructure/storage/lisk/LiskDAO.php | 5 +++ 19 files changed, 192 insertions(+), 19 deletions(-) create mode 100644 src/applications/harbormaster/storage/HarbormasterSchemaSpec.php delete mode 100644 src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 92c32b6977..1f89c6d8af 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -710,7 +710,6 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php', 'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php', 'HarbormasterBuildPlanTransaction' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php', - 'HarbormasterBuildPlanTransactionComment' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php', 'HarbormasterBuildPlanTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanTransactionQuery.php', 'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php', 'HarbormasterBuildStep' => 'applications/harbormaster/storage/configuration/HarbormasterBuildStep.php', @@ -762,6 +761,7 @@ phutil_register_library_map(array( 'HarbormasterQueryBuildablesConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildablesConduitAPIMethod.php', 'HarbormasterQueryBuildsConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php', 'HarbormasterRemarkupRule' => 'applications/harbormaster/remarkup/HarbormasterRemarkupRule.php', + 'HarbormasterSchemaSpec' => 'applications/harbormaster/storage/HarbormasterSchemaSpec.php', 'HarbormasterScratchTable' => 'applications/harbormaster/storage/HarbormasterScratchTable.php', 'HarbormasterSendMessageConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterSendMessageConduitAPIMethod.php', 'HarbormasterSleepBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterSleepBuildStepImplementation.php', @@ -3585,7 +3585,6 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HarbormasterBuildPlanTransaction' => 'PhabricatorApplicationTransaction', - 'HarbormasterBuildPlanTransactionComment' => 'PhabricatorApplicationTransactionComment', 'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildStep' => array( @@ -3649,6 +3648,7 @@ phutil_register_library_map(array( 'HarbormasterQueryBuildablesConduitAPIMethod' => 'HarbormasterConduitAPIMethod', 'HarbormasterQueryBuildsConduitAPIMethod' => 'HarbormasterConduitAPIMethod', 'HarbormasterRemarkupRule' => 'PhabricatorObjectRemarkupRule', + 'HarbormasterSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'HarbormasterScratchTable' => 'HarbormasterDAO', 'HarbormasterSendMessageConduitAPIMethod' => 'HarbormasterConduitAPIMethod', 'HarbormasterSleepBuildStepImplementation' => 'HarbormasterBuildStepImplementation', diff --git a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php index df3500741c..a0da8d4aea 100644 --- a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php @@ -42,6 +42,9 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject { ->loadObjects(); foreach ($objects as $object) { + if ($object->getConfigOption(LiskDAO::CONFIG_NO_TABLE)) { + continue; + } $this->buildLiskObjectSchema($object); } } diff --git a/src/applications/harbormaster/storage/HarbormasterBuildCommand.php b/src/applications/harbormaster/storage/HarbormasterBuildCommand.php index 8b703cad4d..88ad33e904 100644 --- a/src/applications/harbormaster/storage/HarbormasterBuildCommand.php +++ b/src/applications/harbormaster/storage/HarbormasterBuildCommand.php @@ -10,4 +10,17 @@ final class HarbormasterBuildCommand extends HarbormasterDAO { protected $targetPHID; protected $command; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'command' => 'text128', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_target' => array( + 'columns' => array('targetPHID'), + ), + ), + ) + parent::getConfiguration(); + } + } diff --git a/src/applications/harbormaster/storage/HarbormasterBuildMessage.php b/src/applications/harbormaster/storage/HarbormasterBuildMessage.php index e4c31261d1..4ed1c8c7bc 100644 --- a/src/applications/harbormaster/storage/HarbormasterBuildMessage.php +++ b/src/applications/harbormaster/storage/HarbormasterBuildMessage.php @@ -22,6 +22,20 @@ final class HarbormasterBuildMessage extends HarbormasterDAO ->setIsConsumed(0); } + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'type' => 'text16', + 'isConsumed' => 'bool', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_buildtarget' => array( + 'columns' => array('buildTargetPHID'), + ), + ), + ) + parent::getConfiguration(); + } + public function getBuildTarget() { return $this->assertAttached($this->buildTarget); } diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php index e7e1b4b5ed..3e14167ac3 100644 --- a/src/applications/harbormaster/storage/HarbormasterBuildable.php +++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php @@ -155,6 +155,22 @@ final class HarbormasterBuildable extends HarbormasterDAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'containerPHID' => 'phid?', + 'buildableStatus' => 'text32', + 'isManualBuildable' => 'bool', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_buildable' => array( + 'columns' => array('buildablePHID'), + ), + 'key_container' => array( + 'columns' => array('containerPHID'), + ), + 'key_manual' => array( + 'columns' => array('isManualBuildable'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/HarbormasterObject.php b/src/applications/harbormaster/storage/HarbormasterObject.php index 0b8f724212..f83b41a4b9 100644 --- a/src/applications/harbormaster/storage/HarbormasterObject.php +++ b/src/applications/harbormaster/storage/HarbormasterObject.php @@ -2,12 +2,14 @@ final class HarbormasterObject extends HarbormasterDAO { - protected $phid; protected $name; public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php b/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php new file mode 100644 index 0000000000..11ca19c5c5 --- /dev/null +++ b/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php @@ -0,0 +1,45 @@ +buildLiskSchemata('HarbormasterDAO'); + + $this->buildEdgeSchemata(new HarbormasterBuildable()); + $this->buildCounterSchema(new HarbormasterBuildable()); + + $this->buildTransactionSchema( + new HarbormasterBuildableTransaction()); + + $this->buildTransactionSchema( + new HarbormasterBuildTransaction()); + + $this->buildTransactionSchema( + new HarbormasterBuildPlanTransaction()); + + $this->buildTransactionSchema( + new HarbormasterBuildStepTransaction()); + + $this->buildRawSchema( + id(new HarbormasterBuildable())->getApplicationName(), + 'harbormaster_buildlogchunk', + array( + 'id' => 'id', + 'logID' => 'id', + 'encoding' => 'text32', + 'size' => 'uint32', + 'chunk' => 'bytes', + ), + array( + 'PRIMARY' => array( + 'columns' => array('id'), + 'unique' => true, + ), + 'key_log' => array( + 'columns' => array('logID'), + ), + )); + + } + +} diff --git a/src/applications/harbormaster/storage/HarbormasterScratchTable.php b/src/applications/harbormaster/storage/HarbormasterScratchTable.php index 518bdcdc5f..7da7378d71 100644 --- a/src/applications/harbormaster/storage/HarbormasterScratchTable.php +++ b/src/applications/harbormaster/storage/HarbormasterScratchTable.php @@ -11,4 +11,18 @@ final class HarbormasterScratchTable extends HarbormasterDAO { protected $data; protected $bigData; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'data' => 'text64', + 'bigData' => 'text?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'data' => array( + 'columns' => array('data'), + ), + ), + ) + parent::getConfiguration(); + } + } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php index 4c2215a93a..4b05a5937a 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php @@ -143,6 +143,21 @@ final class HarbormasterBuild extends HarbormasterDAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'buildStatus' => 'text32', + 'buildGeneration' => 'uint32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_buildable' => array( + 'columns' => array('buildablePHID'), + ), + 'key_plan' => array( + 'columns' => array('buildPlanPHID'), + ), + 'key_status' => array( + 'columns' => array('buildStatus'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php index 08608a746b..2a760083a4 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php @@ -26,6 +26,20 @@ final class HarbormasterBuildArtifact extends HarbormasterDAO self::CONFIG_SERIALIZATION => array( 'artifactData' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'artifactType' => 'text32', + 'artifactIndex' => 'bytes12', + 'artifactKey' => 'text255', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_artifact' => array( + 'columns' => array('artifactType', 'artifactIndex'), + 'unique' => true, + ), + 'key_garbagecollect' => array( + 'columns' => array('artifactType', 'dateCreated'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php b/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php index ada416eeb5..cc4642ab63 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php @@ -7,6 +7,7 @@ final class HarbormasterBuildItem extends HarbormasterDAO { public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_NO_TABLE => true, ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php index ebdf53246b..8ac71f6a25 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php @@ -30,6 +30,17 @@ final class HarbormasterBuildLog extends HarbormasterDAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'logSource' => 'text255', + 'logType' => 'text255', + 'duration' => 'uint32', + 'live' => 'bool', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_buildtarget' => array( + 'columns' => array('buildTargetPHID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php index 8f9a5b7b8e..c64db741ea 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php @@ -99,7 +99,20 @@ final class HarbormasterBuildTarget extends HarbormasterDAO self::CONFIG_SERIALIZATION => array( 'details' => self::SERIALIZATION_JSON, 'variables' => self::SERIALIZATION_JSON, - ) + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'className' => 'text255', + 'targetStatus' => 'text64', + 'name' => 'text255', + 'dateStarted' => 'epoch?', + 'dateCompleted' => 'epoch?', + 'buildGeneration' => 'uint32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_build' => array( + 'columns' => array('buildPHID', 'buildStepPHID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php index ca11bd746d..abf9db331e 100644 --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php +++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php @@ -21,6 +21,15 @@ final class HarbormasterBuildPlan extends HarbormasterDAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + 'planStatus' => 'text32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_status' => array( + 'columns' => array('planStatus'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php index 9d48339f3e..130471e21b 100644 --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php +++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php @@ -14,10 +14,6 @@ final class HarbormasterBuildPlanTransaction return HarbormasterBuildPlanPHIDType::TYPECONST; } - public function getApplicationTransactionCommentObject() { - return new HarbormasterBuildPlanTransactionComment(); - } - public function getIcon() { $old = $this->getOldValue(); $new = $this->getNewValue(); diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php deleted file mode 100644 index c1ad15d52b..0000000000 --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php +++ /dev/null @@ -1,10 +0,0 @@ - true, self::CONFIG_SERIALIZATION => array( 'details' => self::SERIALIZATION_JSON, - ) + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'className' => 'text255', + 'sequence' => 'uint32', + 'name' => 'text255', + 'description' => 'text', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_plan' => array( + 'columns' => array('buildPlanPHID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/tokens/storage/PhabricatorToken.php b/src/applications/tokens/storage/PhabricatorToken.php index bdcb1cc37a..c435b2dfef 100644 --- a/src/applications/tokens/storage/PhabricatorToken.php +++ b/src/applications/tokens/storage/PhabricatorToken.php @@ -10,6 +10,7 @@ final class PhabricatorToken extends PhabricatorTokenDAO public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_NO_TABLE => true, ) + parent::getConfiguration(); } diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index d5d1e14c11..cd76f29b52 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -171,6 +171,7 @@ abstract class LiskDAO { const CONFIG_BINARY = 'binary'; const CONFIG_COLUMN_SCHEMA = 'col-schema'; const CONFIG_KEY_SCHEMA = 'key-schema'; + const CONFIG_NO_TABLE = 'no-table'; const SERIALIZATION_NONE = 'id'; const SERIALIZATION_JSON = 'json'; @@ -351,6 +352,10 @@ abstract class LiskDAO { * CONFIG_KEY_SCHEMA * Provide a map of key names to key specifications. * + * CONFIG_NO_TABLE + * Allows you to specify that this object does not actually have a table in + * the database. + * * @return dictionary Map of configuration options to values. * * @task config