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
This commit is contained in:
		| @@ -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', | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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); | ||||
|   } | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,45 @@ | ||||
| <?php | ||||
|  | ||||
| final class HarbormasterSchemaSpec extends PhabricatorConfigSchemaSpec { | ||||
|  | ||||
|   public function buildSchemata() { | ||||
|     $this->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'), | ||||
|         ), | ||||
|       )); | ||||
|  | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -1,10 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| final class HarbormasterBuildPlanTransactionComment | ||||
|   extends PhabricatorApplicationTransactionComment { | ||||
|  | ||||
|   public function getApplicationTransactionObject() { | ||||
|     return new HarbormasterBuildPlan(); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -25,7 +25,18 @@ final class HarbormasterBuildStep extends HarbormasterDAO | ||||
|       self::CONFIG_AUX_PHID => 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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 epriestley
					epriestley