John Erling Blad has submitted this change and it was merged. Change subject: Added preliminary definition of two non DV tables of the SQL Store ......................................................................
Added preliminary definition of two non DV tables of the SQL Store Change-Id: I18153d98625a42a32a1c64a9a4c8a4ac1734d4c5 --- M repo/includes/Database/FieldDefinition.php M repo/includes/Query/SQLStore/Setup.php 2 files changed, 132 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index d280e5c..2462155 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -86,8 +86,23 @@ const TYPE_INTEGER = 'int'; const TYPE_FLOAT = 'float'; + const NOT_NULL = false; + const NULL = true; + + const NO_DEFAULT = null; + + const NO_ATTRIB = null; const ATTRIB_BINARY = 'binary'; const ATTRIB_UNSIGNED = 'unsigned'; + + const NO_INDEX = null; + const INDEX = 'index'; + const INDEX_UNIQUE = 'unique'; + const INDEX_FULLTEXT = 'fulltext'; + const INDEX_PRIMARY = 'primary'; + + const AUTOINCREMENT = true; + const NO_AUTOINCREMENT = false; /** @@ -101,7 +116,7 @@ * * @throws InvalidArgumentException */ - public function __construct( $name, $type, $null = true, $default = null, $attributes = null, $index = null, $autoIncrement = false ) { + public function __construct( $name, $type, $null = self::NULL, $default = self::NO_DEFAULT, $attributes = null, $index = null, $autoIncrement = false ) { if ( !is_string( $name ) ) { throw new InvalidArgumentException( 'The field $name needs to be a string' ); } diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 3a2a670..0d82f63 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -5,6 +5,7 @@ use Wikibase\Repo\Database\TableBuilder; use Wikibase\Repo\Database\QueryInterface; use Wikibase\Repo\Database\TableDefinition; +use Wikibase\Repo\Database\FieldDefinition; use MessageReporter; /** @@ -131,6 +132,121 @@ } /** + * TODO + * + * @return TableDefinition[] + */ + private function getNonDVTables() { + $tables = array(); + + // Id map with Wikibase EntityId to internal SQL store id + $tables[] = new TableDefinition( + 'entities', + array( + // Internal id + new FieldDefinition( + 'id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX_PRIMARY, + FieldDefinition::AUTOINCREMENT + ), + + // EntityId type part + new FieldDefinition( + 'type', + FieldDefinition::TYPE_TEXT, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::NO_ATTRIB, + FieldDefinition::INDEX + ), + + // EntityId numerical part + new FieldDefinition( + 'number', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + ) + ); + + // Claim id table + $tables[] = new TableDefinition( + 'claims', + array( + // Internal id + new FieldDefinition( + 'id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX_PRIMARY, + FieldDefinition::AUTOINCREMENT + ), + + // External id + new FieldDefinition( + 'guid', + FieldDefinition::TYPE_TEXT, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Internal id of the claims subject + new FieldDefinition( + 'subject_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Internal id of the property of the main snak + new FieldDefinition( + 'property_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Rank + new FieldDefinition( + 'rank', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Hash + new FieldDefinition( + 'hash', + FieldDefinition::TYPE_TEXT, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::NO_ATTRIB, + FieldDefinition::INDEX + ), + ) + ); + + return $tables; + } + + /** * Sets up the tables of the store. * * @since wd.qe -- To view, visit https://gerrit.wikimedia.org/r/52364 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I18153d98625a42a32a1c64a9a4c8a4ac1734d4c5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Jens Ohlig <jens.oh...@wikimedia.de> Gerrit-Reviewer: John Erling Blad <john.b...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits