https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113059

Revision: 113059
Author:   kipcool
Date:     2012-03-05 18:18:48 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
Created an install script

Added Paths:
-----------
    trunk/extensions/Wikidata/Console/installWikidata.php
    trunk/extensions/Wikidata/Console/wikidataTemplate.sql

Added: trunk/extensions/Wikidata/Console/installWikidata.php
===================================================================
--- trunk/extensions/Wikidata/Console/installWikidata.php                       
        (rev 0)
+++ trunk/extensions/Wikidata/Console/installWikidata.php       2012-03-05 
18:18:48 UTC (rev 113059)
@@ -0,0 +1,243 @@
+<?php
+
+/**
+* Maintenance script to create a wikidata extension for mediawiki
+* it generates the tables in a database (passed as parameter) with a defined 
prefix (passed as parameter)
+*/
+
+$baseDir = dirname( __FILE__ ) . '/../../..' ;
+require_once( $baseDir . '/maintenance/Maintenance.php' );
+
+echo "start\n";
+
+class InstallWikidata extends Maintenance {
+
+       public function __construct() {
+               parent::__construct();
+               $this->mDescription = "Install Wikidata by creating the tables 
and filling them with the minimal necessary data\n"
+                       . 'Example usage: php installWikidata.php --prefix=uw '
+                       . '--template=wikidataTemplate.sql 
--datasetname="OmegaWiki community"' ;
+               $this->addOption( 'prefix', 'The prefix to use for Wikidata 
relational tables. e.g. --prefix=uw' );
+               $this->addOption( 'template', 'A sql template describing the 
relational tables. e.g. --template=wikidataTemplate.sql' );
+               $this->addOption( 'datasetname', 'A name for your dataset. e.g. 
--datasetname="OmegaWiki community"' );
+       }
+
+       public function execute() {
+
+               global $wdCurrentContext;
+
+               // checking that the needed parameters are given
+               if ( !$this->hasOption( 'prefix' ) ) {
+                       $this->output( "A prefix is missing. Use for example 
--prefix=uw\n");
+                       exit(0);
+               }
+               if ( !$this->hasOption( 'template' ) ) {
+                       $this->output( "A template is missing. Use for example 
--template=wikidataTemplate.sql\n");
+                       exit(0);
+               }
+
+               $prefix = $this->getOption( 'prefix' );
+               $template = $this->getOption( 'template' );
+               $datasetname = $this->getOption( 'datasetname' );
+               $wdCurrentContext = $prefix ;
+
+               $this->output( "Creating Wikidata tables...\n" );
+
+               $this->ReadTemplateSQLFile( "/*\$wgWDprefix*/", $prefix . "_", 
dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $template );
+
+               // entering dataset in table wikidata_sets
+               $dbw = wfGetDB( DB_MASTER );
+               $dbw->query( "DELETE FROM wikidata_sets WHERE set_prefix = 
'$prefix'" );
+               $dbw->query( "INSERT INTO wikidata_sets 
(set_prefix,set_fallback_name,set_dmid) VALUES ('$prefix','$datasetname',0)" );
+
+               $this->output( "Adding language English...\n" );
+               $this->createLanguageEnglish( $prefix );
+
+               $this->output( "Filling table 
{$prefix}_bootstrapped_defined_meanings...\n" );
+               $this->bootStrappedDefinedMeanings( $prefix );
+
+               $this->output( "Adding some more data to enable 
annotations...\n" );
+               $this->enableAnnotations( $prefix );
+       }
+
+
+       protected function createLanguageEnglish( $dc ) {
+               $dbw = wfGetDB( DB_MASTER );
+
+               $langname = "English";
+               $langiso6392 = "en";
+               $langiso6393 = "eng";
+               $langwmf = "en";
+               $sql = 'INSERT IGNORE INTO language(language_id, 
iso639_2,iso639_3,wikimedia_key) values('
+                       . WD_ENGLISH_LANG_ID . ','
+                       . $dbw->addQuotes( $langiso6392 ) . ','
+                       . $dbw->addQuotes( $langiso6393 ) . ','
+                       . $dbw->addQuotes( $langwmf ) . ')';
+
+               $dbw->query( $sql );
+
+               $sql = 'INSERT IGNORE INTO 
language_names(language_id,name_language_id,language_name) values ('
+                       . WD_ENGLISH_LANG_ID . ','
+                       . WD_ENGLISH_LANG_ID . ','
+                       . $dbw->addQuotes( $langname ) . ')';
+               $dbw->query( $sql );
+       }
+
+       protected function bootStrappedDefinedMeanings( $dc ) {
+               // Admin user
+               $userId = 1 ;
+               $dbw = wfGetDB( DB_MASTER );
+
+               // check that it is really a fresh install
+               $query = "SELECT * FROM  {$dc}_collection" ;
+               $queryResult = $dbw->query( $query );
+               if ( $dbw->numRows( $queryResult ) > 0 ) {
+                       echo "Table {$dc}_collection not empty.\n" ;
+                       echo "\nERROR: It appears that Wikidata is at least 
already partially installed on your system\n" ;
+                       echo "\nIf you would like to do a fresh install, drop 
the following tables, and run the install script again:\n" ;
+                       $this->printDropTablesCommand( $dc );
+                       exit(0);
+               }
+
+
+               startNewTransaction( $userId, 0, "Script bootstrap class 
attribute meanings", $dc );
+               $collectionId = bootstrapCollection( "Class attribute levels", 
WD_ENGLISH_LANG_ID, "LEVL", $dc );
+
+               $definedMeaningMeaningName = "DefinedMeaning";
+               $definitionMeaningName = "Definition";
+               $relationMeaningName = "Relation";
+               $synTransMeaningName = "SynTrans";
+               $annotationMeaningName = "Annotation";
+
+               $meanings = array();
+               $meanings[$definedMeaningMeaningName] = 
$this->bootstrapDefinedMeaning( $definedMeaningMeaningName, WD_ENGLISH_LANG_ID, 
"The combination of an expression and definition in one language defining a 
concept." );
+               $meanings[$definitionMeaningName] = 
$this->bootstrapDefinedMeaning( $definitionMeaningName, WD_ENGLISH_LANG_ID, "A 
paraphrase describing a concept." );
+               $meanings[$synTransMeaningName] = 
$this->bootstrapDefinedMeaning( $synTransMeaningName, WD_ENGLISH_LANG_ID, "A 
translation or a synonym that is equal or near equal to the concept defined by 
the defined meaning." );
+               $meanings[$relationMeaningName] = 
$this->bootstrapDefinedMeaning( $relationMeaningName, WD_ENGLISH_LANG_ID, "The 
association of two defined meanings through a specific relation type." );
+               $meanings[$annotationMeaningName] = 
$this->bootstrapDefinedMeaning( $annotationMeaningName, WD_ENGLISH_LANG_ID, 
"Characteristic information of a concept." );
+
+               foreach ( $meanings as $internalName => $meaningId ) {
+                       addDefinedMeaningToCollection( $meaningId, 
$collectionId, $internalName );
+
+                       $dbw->query( "INSERT INTO 
`{$dc}_bootstrapped_defined_meanings` (name, defined_meaning_id) " .
+                                       "VALUES (" . $dbw->addQuotes( 
$internalName ) . ", " . $meaningId . ")" );
+               }
+
+       }
+
+       protected function enableAnnotations( $dc ) {
+               // Admin user
+               $userId = 1 ;
+               $dbw = wfGetDB( DB_MASTER );
+
+               startNewTransaction( $userId, 0, "Script bootstrap class 
attribute meanings", $dc );
+
+               // a collection of classes. A word added to that collection 
becomes a class
+               $lexicalCollectionId = bootstrapCollection( "lexical 
functionality", WD_ENGLISH_LANG_ID, "CLAS", $dc );
+
+               // a collection of iso639-3 codes, to enable translation of the 
interface
+               // and language specific annotations
+               $iso6393CollectionId = bootstrapCollection( "ISO 639-3 codes", 
WD_ENGLISH_LANG_ID, "", $dc );
+
+               // DM lexical item, a class by default for every word
+               $lexicalItemDMId = $this->bootstrapDefinedMeaning( "lexical 
item", WD_ENGLISH_LANG_ID, "Lexical item is used as a class by default." );
+               addDefinedMeaningToCollection( $lexicalItemDMId, 
$lexicalCollectionId, "" );
+
+               // DM English, a class by default for English words
+               $englishDMId = $this->bootstrapDefinedMeaning( "English", 
WD_ENGLISH_LANG_ID,
+                       "A West-Germanic language originating in England but 
now spoken in all parts of the British Isles,"
+                       . " the Commonwealth of Nations, the United States of 
America, and other parts of the world."
+               );
+               addDefinedMeaningToCollection( $englishDMId, 
$lexicalCollectionId, "" );
+               addDefinedMeaningToCollection( $englishDMId, 
$iso6393CollectionId, "eng" );
+
+               echo "**\n";
+               echo "Add to your LocalSettings.php: \n";
+               echo '$wgDefaultClassMids = array(' . $lexicalItemDMId . ");\n";
+               echo '$wgIso639_3CollectionId = ' . $iso6393CollectionId . 
";\n";
+               echo "**\n";
+       }
+
+       protected function bootstrapDefinedMeaning( $spelling, $languageId, 
$definition ) {
+               $expression = findOrCreateExpression( $spelling, $languageId );
+               $definedMeaningId = createNewDefinedMeaning( $expression->id, 
$languageId, $definition );
+
+               return $definedMeaningId;
+       }
+
+
+       protected function printDropTablesCommand( $dc ) {
+               $dropCommand = "drop table ";
+               $dropCommand .= $dc . "_alt_meaningtexts, ";
+               $dropCommand .= $dc . "_bootstrapped_defined_meanings, ";
+               $dropCommand .= $dc . "_class_attributes, ";
+               $dropCommand .= $dc . "_class_membership, ";
+               $dropCommand .= $dc . "_collection, ";
+               $dropCommand .= $dc . "_collection_contents, ";
+               $dropCommand .= $dc . "_collection_language, ";
+               $dropCommand .= $dc . "_defined_meaning, ";
+               $dropCommand .= $dc . "_expression, ";
+               $dropCommand .= $dc . "_meaning_relations, ";
+               $dropCommand .= $dc . "_objects, ";
+               $dropCommand .= $dc . "_option_attribute_options, ";
+               $dropCommand .= $dc . "_option_attribute_values, ";
+               $dropCommand .= $dc . "_script_log, ";
+               $dropCommand .= $dc . "_syntrans, ";
+               $dropCommand .= $dc . "_text, ";
+               $dropCommand .= $dc . "_text_attribute_values, ";
+               $dropCommand .= $dc . "_transactions, ";
+               $dropCommand .= $dc . "_translated_content, ";
+               $dropCommand .= $dc . "_translated_content_attribute_values, ";
+               $dropCommand .= $dc . "_url_attribute_values ";
+
+               echo "\n\n$dropCommand\n\n";
+       }
+
+       protected function ReadTemplateSQLFile( $pattern, $prefix, $filename ) {
+               $dbw = wfGetDB( DB_MASTER );
+
+               $fp = fopen( $filename, 'r' );
+               if ( false === $fp ) {
+                       return "Could not open \"{$filename}\".\n";
+               }
+
+               $cmd = "";
+               $done = false;
+
+               while ( ! feof( $fp ) ) {
+                       $line = trim( fgets( $fp, 1024 ) );
+                       $sl = strlen( $line ) - 1;
+
+                       if ( $sl < 0 ) { continue; }
+                       if ( '-' == $line { 0 } && '-' == $line { 1 } ) { 
continue; }
+
+                       if ( ';' == $line { $sl } && ( $sl < 2 || ';' != $line 
{ $sl - 1 } ) ) {
+                               $done = true;
+                               $line = substr( $line, 0, $sl );
+                       }
+
+                       if ( '' != $cmd ) { $cmd .= ' '; }
+                       $cmd .= "$line\n";
+
+                       if ( $done ) {
+                               $cmd = str_replace( ';;', ";", $cmd );
+                               $cmd = trim( str_replace( $pattern, $prefix, 
$cmd ) );
+
+                               $res = $dbw->query( $cmd );
+
+                               if ( false === $res ) {
+                                       return "Query \"{$cmd}\" failed with 
error code \".\n";
+                               }
+
+                               $cmd = '';
+                               $done = false;
+                       }
+               }
+               fclose( $fp );
+               return true;
+       }
+
+}
+
+$maintClass = 'InstallWikidata';
+require_once( RUN_MAINTENANCE_IF_MAIN );
\ No newline at end of file


Property changes on: trunk/extensions/Wikidata/Console/installWikidata.php
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/extensions/Wikidata/Console/wikidataTemplate.sql
===================================================================
--- trunk/extensions/Wikidata/Console/wikidataTemplate.sql                      
        (rev 0)
+++ trunk/extensions/Wikidata/Console/wikidataTemplate.sql      2012-03-05 
18:18:48 UTC (rev 113059)
@@ -0,0 +1,304 @@
+--
+-- Add the wikidata specific namespaces
+--
+ 
+CREATE TABLE IF NOT EXISTS language (
+  language_id int(10) NOT NULL auto_increment,
+  dialect_of_lid int(10) NOT NULL default '0',
+  iso639_2 varchar(10) collate utf8_bin NOT NULL default '',
+  iso639_3 varchar(10) collate utf8_bin NOT NULL default '',
+  wikimedia_key varchar(10) collate utf8_bin NOT NULL default '',
+  PRIMARY KEY  (language_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+
+CREATE TABLE IF NOT EXISTS language_names (
+  language_id int(10) NOT NULL default '0',
+  name_language_id int(10) NOT NULL default '0',
+  language_name varchar(255) NOT NULL default '',
+  PRIMARY KEY  (language_id,name_language_id),
+  KEY language_id (language_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+
+CREATE TABLE IF NOT EXISTS wikidata_sets (
+  set_prefix varchar(20) default NULL,
+  set_fallback_name varchar(255) default NULL,
+  set_dmid int(10) default NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/alt_meaningtexts (
+  `meaning_mid` int(10) default NULL,
+  `meaning_text_tcid` int(10) default NULL,
+  `source_id` int(11) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_meaning 
(`remove_transaction_id`,`meaning_mid`,`meaning_text_tcid`,`source_id`),
+  KEY /*$wgWDprefix*/versioned_end_text 
(`remove_transaction_id`,`meaning_text_tcid`,`meaning_mid`,`source_id`),
+  KEY /*$wgWDprefix*/versioned_end_source 
(`remove_transaction_id`,`source_id`,`meaning_mid`,`meaning_text_tcid`),
+  KEY /*$wgWDprefix*/versioned_start_meaning 
(`add_transaction_id`,`meaning_mid`,`meaning_text_tcid`,`source_id`),
+  KEY /*$wgWDprefix*/versioned_start_text 
(`add_transaction_id`,`meaning_text_tcid`,`meaning_mid`,`source_id`),
+  KEY /*$wgWDprefix*/versioned_start_source 
(`add_transaction_id`,`source_id`,`meaning_mid`,`meaning_text_tcid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/bootstrapped_defined_meanings (
+  `name` varchar(255) NOT NULL,
+  `defined_meaning_id` int(11) NOT NULL,
+  KEY /*$wgWDprefix*/unversioned_meaning (`defined_meaning_id`),
+  KEY /*$wgWDprefix*/unversioned_name (`name` (255),`defined_meaning_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+-- object_id - key for the attribute, used elsewhere as a foreign key
+-- class_mid - which class (identified by DMID) has this attribute?
+-- level_mid - on which level can we annotate: Annotation, DefinedMeaning, 
Definition, Relation, SynTrans; these are also cached in 
*_bootstrapped_defined_meanings
+-- attribute_mid - which attribute are we describing?
+-- attribute_type - what kind of information are we talking about? can be 
'DM', 'TRNS' (translatable text), 'TEXT', 'URL', 'OPTN' (multiple DMs to choose 
from)a
+-- attribute_id - refers to the object_id from xx_class_attributes
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/class_attributes (
+  `object_id` int(11) NOT NULL,
+  `class_mid` int(11) NOT NULL default '0',
+  `level_mid` int(11) NOT NULL,
+  `attribute_mid` int(11) NOT NULL default '0',
+  `attribute_type` char(4) collate utf8_bin NOT NULL default 'TEXT',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_class 
(`remove_transaction_id`,`class_mid`,`attribute_mid`,`object_id`),
+  KEY /*$wgWDprefix*/versioned_end_attribute 
(`remove_transaction_id`,`attribute_mid`,`class_mid`,`object_id`),
+  KEY /*$wgWDprefix*/versioned_end_object 
(`remove_transaction_id`,`object_id`),
+  KEY /*$wgWDprefix*/versioned_start_class 
(`add_transaction_id`,`class_mid`,`attribute_mid`,`object_id`),
+  KEY /*$wgWDprefix*/versioned_start_attribute 
(`add_transaction_id`,`attribute_mid`,`class_mid`,`object_id`),
+  KEY /*$wgWDprefix*/versioned_start_object (`add_transaction_id`,`object_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/class_membership (
+  `class_membership_id` int(11) NOT NULL,
+  `class_mid` int(11) NOT NULL default '0',
+  `class_member_mid` int(11) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_class 
(`remove_transaction_id`,`class_mid`,`class_member_mid`),
+  KEY /*$wgWDprefix*/versioned_end_class_member 
(`remove_transaction_id`,`class_member_mid`,`class_mid`),
+  KEY /*$wgWDprefix*/versioned_end_class_membership 
(`remove_transaction_id`,`class_membership_id`),
+  KEY /*$wgWDprefix*/versioned_start_class 
(`add_transaction_id`,`class_mid`,`class_member_mid`),
+  KEY /*$wgWDprefix*/versioned_start_class_member 
(`add_transaction_id`,`class_member_mid`,`class_mid`),
+  KEY /*$wgWDprefix*/versioned_start_class_membership 
(`add_transaction_id`,`class_membership_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/collection_contents (
+`object_id` int(11) default NULL,
+  `collection_id` int(10) NOT NULL default '0',
+  `member_mid` int(10) NOT NULL default '0',
+  `internal_member_id` varchar(255) default NULL,
+  `applicable_language_id` int(10) default NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_collection 
(`remove_transaction_id`,`collection_id`,`member_mid`),
+  KEY /*$wgWDprefix*/versioned_end_collection_member 
(`remove_transaction_id`,`member_mid`,`collection_id`),
+  KEY /*$wgWDprefix*/versioned_end_internal_id 
(`remove_transaction_id`,`internal_member_id`,`collection_id`,`member_mid`),
+  KEY /*$wgWDprefix*/versioned_start_collection 
(`add_transaction_id`,`collection_id`,`member_mid`),
+  KEY /*$wgWDprefix*/versioned_start_collection_member 
(`add_transaction_id`,`member_mid`,`collection_id`),
+  KEY /*$wgWDprefix*/versioned_start_internal_id 
(`add_transaction_id`,`internal_member_id`,`collection_id`,`member_mid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/collection_language (
+  `collection_id` int(10) NOT NULL default '0',
+  `language_id` int(10) NOT NULL default '0'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/collection (
+  `collection_id` int(10) unsigned NOT NULL,
+  `collection_mid` int(10) NOT NULL default '0',
+  `collection_type` char(4) default NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_collection 
(`remove_transaction_id`,`collection_id`,`collection_mid`),
+  KEY /*$wgWDprefix*/versioned_end_collection_meaning 
(`remove_transaction_id`,`collection_mid`,`collection_id`),
+  KEY /*$wgWDprefix*/versioned_end_collection_type 
(`remove_transaction_id`,`collection_type` 
(4),`collection_id`,`collection_mid`),
+  KEY /*$wgWDprefix*/versioned_start_collection 
(`add_transaction_id`,`collection_id`,`collection_mid`),
+  KEY /*$wgWDprefix*/versioned_start_collection_meaning 
(`add_transaction_id`,`collection_mid`,`collection_id`),
+  KEY /*$wgWDprefix*/versioned_start_collection_type 
(`add_transaction_id`,`collection_type` (4),`collection_id`,`collection_mid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/defined_meaning (
+  `defined_meaning_id` int(8) unsigned NOT NULL,
+  `expression_id` int(10) NOT NULL,
+  `meaning_text_tcid` int(10) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_meaning 
(`remove_transaction_id`,`defined_meaning_id`,`expression_id`),
+  KEY /*$wgWDprefix*/versioned_end_expression 
(`remove_transaction_id`,`expression_id`,`defined_meaning_id`),
+  KEY /*$wgWDprefix*/versioned_end_meaning_text 
(`remove_transaction_id`,`meaning_text_tcid`,`defined_meaning_id`),
+  KEY /*$wgWDprefix*/versioned_start_meaning 
(`add_transaction_id`,`defined_meaning_id`,`expression_id`),
+  KEY /*$wgWDprefix*/versioned_start_expression 
(`add_transaction_id`,`expression_id`,`defined_meaning_id`),
+  KEY /*$wgWDprefix*/versioned_start_meaning_text 
(`add_transaction_id`,`meaning_text_tcid`,`defined_meaning_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/expression (
+  `expression_id` int(10) unsigned NOT NULL,
+  `spelling` varchar(255) NOT NULL default '',
+  `language_id` int(10) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_expression 
(`remove_transaction_id`,`expression_id`,`language_id`),
+  KEY /*$wgWDprefix*/versioned_end_language 
(`remove_transaction_id`,`language_id`,`expression_id`),
+  KEY /*$wgWDprefix*/versioned_end_spelling 
(`remove_transaction_id`,`spelling`(255),`expression_id`,`language_id`),
+  KEY /*$wgWDprefix*/versioned_start_expression 
(`add_transaction_id`,`expression_id`,`language_id`),
+  KEY /*$wgWDprefix*/versioned_start_language 
(`add_transaction_id`,`language_id`,`expression_id`),
+  KEY /*$wgWDprefix*/versioned_start_spelling 
(`add_transaction_id`,`spelling`,`expression_id`,`language_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/meaning_relations (
+  `relation_id` int(11) NOT NULL,
+  `meaning1_mid` int(10) NOT NULL default '0',
+  `meaning2_mid` int(10) NOT NULL default '0',
+  `relationtype_mid` int(10) default NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_outgoing 
(`remove_transaction_id`,`meaning1_mid`,`relationtype_mid`,`meaning2_mid`),
+  KEY /*$wgWDprefix*/versioned_end_incoming 
(`remove_transaction_id`,`meaning2_mid`,`relationtype_mid`,`meaning1_mid`),
+  KEY /*$wgWDprefix*/versioned_end_relation 
(`remove_transaction_id`,`relation_id`),
+  KEY /*$wgWDprefix*/versioned_start_outgoing 
(`add_transaction_id`,`meaning1_mid`,`relationtype_mid`,`meaning2_mid`),
+  KEY /*$wgWDprefix*/versioned_start_incoming 
(`add_transaction_id`,`meaning2_mid`,`relationtype_mid`,`meaning1_mid`),
+  KEY /*$wgWDprefix*/versioned_start_relation 
(`add_transaction_id`,`relation_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/objects (
+  `object_id` int(11) NOT NULL auto_increment,
+  `table` varchar(100) collate utf8_bin NOT NULL,
+  `original_id` int(11) default NULL,
+  `UUID` varchar(36) collate utf8_bin NOT NULL,
+  PRIMARY KEY  (`object_id`),
+  KEY `table` (`table`),
+  KEY `original_id` (`original_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+-- attribute_id - refers to the object_id from xx_class_attributes
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/option_attribute_options (
+  `option_id` int(11) NOT NULL default '0',
+  `attribute_id` int(11) NOT NULL default '0',
+  `option_mid` int(11) NOT NULL default '0',
+  `language_id` int(11) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL default '0',
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_option 
(`remove_transaction_id`,`option_mid`,`attribute_id`,`option_id`),
+  KEY /*$wgWDprefix*/versioned_end_attribute 
(`remove_transaction_id`,`attribute_id`,`option_id`,`option_mid`),
+  KEY /*$wgWDprefix*/versioned_end_id (`remove_transaction_id`,`option_id`),
+  KEY /*$wgWDprefix*/versioned_start_option 
(`add_transaction_id`,`option_mid`,`attribute_id`,`option_id`),
+  KEY /*$wgWDprefix*/versioned_start_attribute 
(`add_transaction_id`,`attribute_id`,`option_id`,`option_mid`),
+  KEY /*$wgWDprefix*/versioned_start_id (`add_transaction_id`,`option_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/option_attribute_values (
+  `value_id` int(11) NOT NULL default '0',
+  `object_id` int(11) NOT NULL default '0',
+  `option_id` int(11) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL default '0',
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_object 
(`remove_transaction_id`,`object_id`,`option_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_option 
(`remove_transaction_id`,`option_id`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_value (`remove_transaction_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_object 
(`add_transaction_id`,`object_id`,`option_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_option 
(`add_transaction_id`,`option_id`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_value (`add_transaction_id`,`value_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/script_log (
+  `script_id` int(11) NOT NULL default '0',
+  `time` datetime NOT NULL default '0000-00-00 00:00:00',
+  `script_name` varchar(128) collate utf8_bin NOT NULL default '',
+  `comment` varchar(128) collate utf8_bin NOT NULL default ''
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/syntrans (
+  `syntrans_sid` int(10) NOT NULL default '0',
+  `defined_meaning_id` int(10) NOT NULL default '0',
+  `expression_id` int(10) NOT NULL,
+  `identical_meaning` tinyint(1) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_syntrans 
(`remove_transaction_id`,`syntrans_sid`),
+  KEY /*$wgWDprefix*/versioned_end_expression 
(`remove_transaction_id`,`expression_id`,`identical_meaning`,`defined_meaning_id`),
+  KEY /*$wgWDprefix*/versioned_end_defined_meaning 
(`remove_transaction_id`,`defined_meaning_id`,`identical_meaning`,`expression_id`),
+  KEY /*$wgWDprefix*/versioned_start_syntrans 
(`add_transaction_id`,`syntrans_sid`),
+  KEY /*$wgWDprefix*/versioned_start_expression 
(`add_transaction_id`,`expression_id`,`identical_meaning`,`defined_meaning_id`),
+  KEY /*$wgWDprefix*/versioned_start_defined_meaning 
(`add_transaction_id`,`defined_meaning_id`,`identical_meaning`,`expression_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/text (
+  `text_id` int(8) unsigned NOT NULL auto_increment,
+  `text_text` mediumblob NOT NULL,
+  `text_flags` tinyblob default NULL,
+  PRIMARY KEY  (`text_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/text_attribute_values (
+  `value_id` int(11) NOT NULL,
+  `object_id` int(11) NOT NULL,
+  `attribute_mid` int(11) NOT NULL,
+  `text` mediumblob NOT NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_object 
(`remove_transaction_id`,`object_id`,`attribute_mid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_attribute 
(`remove_transaction_id`,`attribute_mid`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_value (`remove_transaction_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_object 
(`add_transaction_id`,`object_id`,`attribute_mid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_attribute 
(`add_transaction_id`,`attribute_mid`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_value (`add_transaction_id`,`value_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/transactions (
+  `transaction_id` int(11) NOT NULL auto_increment,
+  `user_id` int(5) NOT NULL,
+  `user_ip` varchar(15) NOT NULL,
+  `timestamp` varchar(14) NOT NULL,
+  `comment` tinyblob NOT NULL,
+  PRIMARY KEY  (`transaction_id`),
+  KEY `user` (`user_id`,`transaction_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/translated_content (
+  `translated_content_id` int(11) NOT NULL default '0',
+  `language_id` int(10) NOT NULL default '0',
+  `text_id` int(10) NOT NULL default '0',
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_translated_content 
(`remove_transaction_id`,`translated_content_id`,`language_id`,`text_id`),
+  KEY /*$wgWDprefix*/versioned_end_text 
(`remove_transaction_id`,`text_id`,`translated_content_id`,`language_id`),
+  KEY /*$wgWDprefix*/versioned_start_translated_content 
(`add_transaction_id`,`translated_content_id`,`language_id`,`text_id`),
+  KEY /*$wgWDprefix*/versioned_start_text 
(`add_transaction_id`,`text_id`,`translated_content_id`,`language_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/translated_content_attribute_values (
+  `value_id` int(11) NOT NULL default '0',
+  `object_id` int(11) NOT NULL,
+  `attribute_mid` int(11) NOT NULL,
+  `value_tcid` int(11) NOT NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_object 
(`remove_transaction_id`,`object_id`,`attribute_mid`,`value_tcid`),
+  KEY /*$wgWDprefix*/versioned_end_attribute 
(`remove_transaction_id`,`attribute_mid`,`object_id`,`value_tcid`),
+  KEY /*$wgWDprefix*/versioned_end_translated_content 
(`remove_transaction_id`,`value_tcid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_value (`remove_transaction_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_object 
(`add_transaction_id`,`object_id`,`attribute_mid`,`value_tcid`),
+  KEY /*$wgWDprefix*/versioned_start_attribute 
(`add_transaction_id`,`attribute_mid`,`object_id`,`value_tcid`),
+  KEY /*$wgWDprefix*/versioned_start_translated_content 
(`add_transaction_id`,`value_tcid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_value (`add_transaction_id`,`value_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+
+CREATE TABLE IF NOT EXISTS /*$wgWDprefix*/url_attribute_values (
+  `value_id` int(11) NOT NULL,
+  `object_id` int(11) NOT NULL,
+  `attribute_mid` int(11) NOT NULL,
+  `url` varchar(255) collate utf8_bin NOT NULL,
+  `label` varchar(255) collate utf8_bin NOT NULL,
+  `add_transaction_id` int(11) NOT NULL,
+  `remove_transaction_id` int(11) default NULL,
+  KEY /*$wgWDprefix*/versioned_end_object 
(`remove_transaction_id`,`object_id`,`attribute_mid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_attribute 
(`remove_transaction_id`,`attribute_mid`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_end_value (`remove_transaction_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_object 
(`add_transaction_id`,`object_id`,`attribute_mid`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_attribute 
(`add_transaction_id`,`attribute_mid`,`object_id`,`value_id`),
+  KEY /*$wgWDprefix*/versioned_start_value (`add_transaction_id`,`value_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;  
+


Property changes on: trunk/extensions/Wikidata/Console/wikidataTemplate.sql
___________________________________________________________________
Added: svn:eol-style
   + native


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to