Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/319358

Change subject: Add primary keys to the remaining Flow tables
......................................................................

Add primary keys to the remaining Flow tables

flow_subscription, flow_topic_list and flow_tree_node.

Bug: T149819
Change-Id: If081234da3a446a6861705c662f5629396618719
---
M Hooks.php
A db_patches/patch-primary-keys.sql
M flow.sql
3 files changed, 18 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/58/319358/1

diff --git a/Hooks.php b/Hooks.php
index 1345ac0..63bddb5 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -235,6 +235,7 @@
                $updater->addExtensionField( 'flow_wiki_ref', 'ref_src_wiki', 
"$dir/db_patches/patch-reference_wiki.sql" );
                $updater->addExtensionField( 'flow_wiki_ref', 'ref_id', 
"$dir/db_patches/patch-ref_id-phase1.sql" );
                $updater->modifyExtensionField( 'flow_ext_ref', 'ref_target', 
"$dir/db_patches/patch-ref_target_not_null.sql" );
+               $updater->dropExtensionIndex( 'flow_topic_list', 
'flow_topic_list_pk', "$dir/db_patches/patch-primary-keys.sql" );
 
                require_once __DIR__.'/maintenance/FlowUpdateRecentChanges.php';
                $updater->addPostDatabaseUpdateMaintenance( 
'FlowUpdateRecentChanges' );
diff --git a/db_patches/patch-primary-keys.sql 
b/db_patches/patch-primary-keys.sql
new file mode 100644
index 0000000..2553334
--- /dev/null
+++ b/db_patches/patch-primary-keys.sql
@@ -0,0 +1,8 @@
+DROP INDEX /*i*/flow_subscription_unique_user_workflow ON 
/*_*/flow_subscription;
+ALTER TABLE /*_*/flow_subscription_unique_user_workflow ADD PRIMARY KEY 
(subscription_workflow_id, subscription_user_id, subscription_user_wiki);
+
+DROP INDEX /*i*/flow_topic_list_pk ON /*_*/flow_topic_list;
+ALTER TABLE /*_*/flow_topic_list ADD PRIMARY KEY (topic_list_id, topic_id);
+
+DROP INDEX /*i*/flow_tree_node_pk ON /*_*/flow_tree_node;
+ALTER TABLE /*_*/flow_tree_node ADD PRIMARY KEY (tree_ancestor_id, 
tree_descendant_id);
diff --git a/flow.sql b/flow.sql
index f6365b1..5443458 100644
--- a/flow.sql
+++ b/flow.sql
@@ -9,7 +9,7 @@
        workflow_title_text varchar(255) binary not null,
     workflow_name varchar(255) binary not null,
        workflow_last_update_timestamp binary(14) not null,
-       -- TODO: is this usefull as a bitfield?  may be premature optimization, 
a string
+       -- TODO: is this useful as a bitfield?  may be premature optimization, 
a string
        -- or list of strings may be simpler and use only a little more space.
        workflow_lock_state int unsigned not null,
        workflow_type varbinary(16) not null,
@@ -24,19 +24,19 @@
   subscription_user_id bigint unsigned not null,
   subscription_user_wiki varchar(64) binary not null,
   subscription_create_timestamp varchar(14) binary not null,
-  subscription_last_updated varchar(14) binary not null
+  subscription_last_updated varchar(14) binary not null,
+  PRIMARY KEY (subscription_workflow_id, subscription_user_id, 
subscription_user_wiki)
 ) /*$wgDBTableOptions*/;
 
-CREATE UNIQUE INDEX /*i*/flow_subscription_unique_user_workflow ON 
/*_*/flow_subscription (subscription_workflow_id, subscription_user_id, 
subscription_user_wiki );
 CREATE INDEX /*i*/flow_subscription_lookup ON /*_*/flow_subscription 
(subscription_user_id, subscription_user_wiki, subscription_last_updated, 
subscription_workflow_id);
 
 -- TopicList Tables
 CREATE TABLE /*_*/flow_topic_list (
        topic_list_id binary(11) not null,
-       topic_id binary(11)
+       topic_id binary(11),
+       PRIMARY KEY (topic_list_id, topic_id)
 ) /*$wgDBTableOptions*/;
 
-CREATE UNIQUE INDEX /*i*/flow_topic_list_pk ON /*_*/flow_topic_list( 
topic_list_id, topic_id);
 CREATE INDEX /*i*/flow_topic_list_topic_id ON /*_*/flow_topic_list (topic_id);
 
 -- Post Content Revisions.  Connects 1 Post to Many revisions.
@@ -53,11 +53,10 @@
        -- denormalize post parent as well? Prevents an extra query when 
building
        -- tree from closure table.  unnecessary?
        tree_parent_id binary(11),
-       PRIMARY KEY( tree_rev_id )
+       PRIMARY KEY(tree_rev_id)
 ) /*$wgDBTableOptions*/;
 
-CREATE INDEX /*i*/flow_tree_descendant_rev_id
-       ON /*_*/flow_tree_revision ( tree_rev_descendant_id, tree_rev_id );
+CREATE INDEX /*i*/flow_tree_descendant_rev_id ON /*_*/flow_tree_revision 
(tree_rev_descendant_id, tree_rev_id);
 
 -- Content
 -- This is completely unoptimized right now, just a quick get-it-done for
@@ -132,10 +131,10 @@
 CREATE TABLE /*_*/flow_tree_node (
        tree_ancestor_id binary(11) not null,
        tree_descendant_id binary(11) not null,
-       tree_depth smallint not null
+       tree_depth smallint not null,
+       PRIMARY KEY (tree_ancestor_id, tree_descendant_id)
 ) /*$wgDBTableOptions*/;
 
-CREATE UNIQUE INDEX /*i*/flow_tree_node_pk ON /*_*/flow_tree_node 
(tree_ancestor_id, tree_descendant_id);
 CREATE UNIQUE INDEX /*i*/flow_tree_constraint ON /*_*/flow_tree_node 
(tree_descendant_id, tree_depth);
 
 CREATE TABLE /*_*/flow_wiki_ref (

-- 
To view, visit https://gerrit.wikimedia.org/r/319358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If081234da3a446a6861705c662f5629396618719
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to