summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Flow/db_patches')
-rw-r--r--Flow/db_patches/patch-88bit_uuids.sql20
-rw-r--r--Flow/db_patches/patch-88bit_uuids.sqlite.sql20
-rw-r--r--Flow/db_patches/patch-add-linkstables.sql32
-rw-r--r--Flow/db_patches/patch-add-revision-content-length.sql3
-rw-r--r--Flow/db_patches/patch-add-wiki.sql16
-rw-r--r--Flow/db_patches/patch-add_workflow_type.sql6
-rw-r--r--Flow/db_patches/patch-add_workflow_type.sqlite.sql10
-rw-r--r--Flow/db_patches/patch-censor_to_suppress.sql12
-rw-r--r--Flow/db_patches/patch-default_null_workflow_user.sql4
-rw-r--r--Flow/db_patches/patch-default_null_workflow_user.sqlite.sql30
-rw-r--r--Flow/db_patches/patch-drop_definition.sql3
-rw-r--r--Flow/db_patches/patch-drop_workflow_user.sql4
-rw-r--r--Flow/db_patches/patch-flow_tree_idx_fix.sql4
-rw-r--r--Flow/db_patches/patch-increase_width_wiki_fields.sql11
-rw-r--r--Flow/db_patches/patch-moderation_reason.sql3
-rw-r--r--Flow/db_patches/patch-rc_source.sql4
-rw-r--r--Flow/db_patches/patch-remove_unique_ref_indices.sql15
-rw-r--r--Flow/db_patches/patch-remove_usernames.sql12
-rw-r--r--Flow/db_patches/patch-remove_usernames_2.sql8
-rw-r--r--Flow/db_patches/patch-rev_change_type.sql2
-rw-r--r--Flow/db_patches/patch-rev_change_type.sqlite.sql50
-rw-r--r--Flow/db_patches/patch-rev_change_type_update.sql14
-rw-r--r--Flow/db_patches/patch-rev_type_id.sql4
-rw-r--r--Flow/db_patches/patch-revision_last_editor.sql7
-rw-r--r--Flow/db_patches/patch-revision_user_idx.sql2
-rw-r--r--Flow/db_patches/patch-revision_user_ip.sql3
-rw-r--r--Flow/db_patches/patch-subscription_user_id.sql3
-rw-r--r--Flow/db_patches/patch-summary2header.sql9
-rw-r--r--Flow/db_patches/patch-summary2header.sqlite.sql21
-rw-r--r--Flow/db_patches/patch-topic_list_topic_id_idx.sql1
-rw-r--r--Flow/db_patches/patch-tree_orig_create_time.sql2
-rw-r--r--Flow/db_patches/patch-workflow_lookup_idx.sql1
32 files changed, 336 insertions, 0 deletions
diff --git a/Flow/db_patches/patch-88bit_uuids.sql b/Flow/db_patches/patch-88bit_uuids.sql
new file mode 100644
index 00000000..fc40a65a
--- /dev/null
+++ b/Flow/db_patches/patch-88bit_uuids.sql
@@ -0,0 +1,20 @@
+ALTER TABLE /*_*/flow_workflow
+ CHANGE workflow_id workflow_id binary(11) not null;
+
+ALTER TABLE /*_*/flow_topic_list
+ CHANGE topic_list_id topic_list_id binary(11) not null,
+ CHANGE topic_id topic_id binary(11) default null;
+
+ALTER TABLE /*_*/flow_tree_revision
+ CHANGE tree_rev_descendant_id tree_rev_descendant_id binary(11) not null,
+ CHANGE tree_rev_id tree_rev_id binary(11) not null,
+ CHANGE tree_parent_id tree_parent_id binary(11) default null;
+
+ALTER TABLE /*_*/flow_revision
+ CHANGE rev_id rev_id binary(11) not null,
+ CHANGE rev_parent_id rev_parent_id binary(11) default null,
+ CHANGE rev_last_edit_id rev_last_edit_id binary(11) default null;
+
+ALTER TABLE /*_*/flow_tree_node
+ CHANGE tree_ancestor_id tree_ancestor_id binary(11) not null,
+ CHANGE tree_descendant_id tree_descendant_id binary(11) not null;
diff --git a/Flow/db_patches/patch-88bit_uuids.sqlite.sql b/Flow/db_patches/patch-88bit_uuids.sqlite.sql
new file mode 100644
index 00000000..a1076941
--- /dev/null
+++ b/Flow/db_patches/patch-88bit_uuids.sqlite.sql
@@ -0,0 +1,20 @@
+UPDATE /*_*/flow_topic_list
+ SET topic_list_id = substr( topic_list_id, 1, 11 ),
+ topic_id = substr( topic_id, 1, 11 );
+
+UPDATE /*_*/flow_workflow
+ SET workflow_id = substr( workflow_id, 1, 11 );
+
+UPDATE /*_*/flow_tree_revision
+ SET tree_rev_descendant_id = substr( tree_rev_descendant_id, 1, 11 ),
+ tree_rev_id = substr( tree_rev_id, 1, 11 ),
+ tree_parent_id = substr( tree_parent_id, 1, 11 );
+
+UPDATE /*_*/flow_revision
+ SET rev_id = substr( rev_id, 1, 11 ),
+ rev_parent_id = substr( rev_parent_id, 1, 11 ),
+ rev_last_edit_id = substr( rev_last_edit_id, 1, 11 );
+
+UPDATE /*_*/flow_tree_node
+ SET tree_ancestor_id = substr( tree_ancestor_id, 1, 11 ),
+ tree_descendant_id = substr( tree_descendant_id, 1, 11 );
diff --git a/Flow/db_patches/patch-add-linkstables.sql b/Flow/db_patches/patch-add-linkstables.sql
new file mode 100644
index 00000000..39564ee8
--- /dev/null
+++ b/Flow/db_patches/patch-add-linkstables.sql
@@ -0,0 +1,32 @@
+CREATE TABLE /*_*/flow_wiki_ref (
+ ref_src_object_id binary(11) not null,
+ ref_src_object_type varbinary(32) not null,
+ ref_src_workflow_id binary(11) not null,
+ ref_src_namespace int not null,
+ ref_src_title varbinary(255) not null,
+ ref_target_namespace int not null,
+ ref_target_title varbinary(255) not null,
+ ref_type varbinary(16) not null
+);
+
+CREATE UNIQUE INDEX /*i*/flow_wiki_ref_pk ON /*_*/flow_wiki_ref
+ (ref_src_namespace, ref_src_title, ref_type, ref_target_namespace, ref_target_title, ref_src_object_type, ref_src_object_id);
+
+CREATE UNIQUE INDEX /*i*/flow_wiki_ref_revision ON /*_*/flow_wiki_ref
+ (ref_src_namespace, ref_src_title, ref_src_object_type, ref_src_object_id, ref_type, ref_target_namespace, ref_target_title);
+
+CREATE TABLE /*_*/flow_ext_ref (
+ ref_src_object_id binary(11) not null,
+ ref_src_object_type varbinary(32) not null,
+ ref_src_workflow_id binary(11) not null,
+ ref_src_namespace int not null,
+ ref_src_title varbinary(255) not null,
+ ref_target varbinary(255) not null,
+ ref_type varbinary(16) not null
+);
+
+CREATE UNIQUE INDEX /*i*/flow_ext_ref_pk ON /*_*/flow_ext_ref
+ (ref_src_namespace, ref_src_title, ref_type, ref_target, ref_src_object_type, ref_src_object_id);
+
+CREATE UNIQUE INDEX /*i*/flow_ext_ref_revision ON /*_*/flow_ext_ref
+ (ref_src_namespace, ref_src_title, ref_src_object_type, ref_src_object_id, ref_type, ref_target);
diff --git a/Flow/db_patches/patch-add-revision-content-length.sql b/Flow/db_patches/patch-add-revision-content-length.sql
new file mode 100644
index 00000000..95f4fd0a
--- /dev/null
+++ b/Flow/db_patches/patch-add-revision-content-length.sql
@@ -0,0 +1,3 @@
+ALTER TABLE flow_revision
+ ADD rev_content_length int NOT NULL DEFAULT 0,
+ ADD rev_previous_content_length int NOT NULL DEFAULT 0;
diff --git a/Flow/db_patches/patch-add-wiki.sql b/Flow/db_patches/patch-add-wiki.sql
new file mode 100644
index 00000000..969fd32f
--- /dev/null
+++ b/Flow/db_patches/patch-add-wiki.sql
@@ -0,0 +1,16 @@
+
+ALTER TABLE /*_*/flow_subscription ADD subscription_user_wiki varchar(32) binary not null;
+
+ALTER TABLE /*_*/flow_tree_revision ADD tree_orig_user_wiki varchar(32) binary not null;
+
+ALTER TABLE /*_*/flow_revision ADD rev_user_wiki varchar(32) binary not null;
+
+ALTER TABLE /*_*/flow_revision ADD rev_mod_user_wiki varchar(32) binary default null;
+
+ALTER TABLE /*_*/flow_revision ADD rev_edit_user_wiki varchar(32) binary default null;
+
+DROP INDEX /*i*/flow_subscription_unique_user_workflow ON /*_*/flow_subscription;
+CREATE UNIQUE INDEX /*i*/flow_subscription_unique_user_workflow ON /*_*/flow_subscription (subscription_workflow_id, subscription_user_id, subscription_user_wiki );
+
+DROP INDEX /*i*/flow_subscription_lookup ON /*_*/flow_subscription;
+CREATE INDEX /*i*/flow_subscription_lookup ON /*_*/flow_subscription (subscription_user_id, subscription_user_wiki, subscription_last_updated, subscription_workflow_id);
diff --git a/Flow/db_patches/patch-add_workflow_type.sql b/Flow/db_patches/patch-add_workflow_type.sql
new file mode 100644
index 00000000..8b6192af
--- /dev/null
+++ b/Flow/db_patches/patch-add_workflow_type.sql
@@ -0,0 +1,6 @@
+
+ALTER TABLE /*_*/flow_workflow ADD workflow_type varbinary(16);
+
+UPDATE /*_*/flow_workflow, /*_*/flow_definition
+ SET workflow_type = definition_type
+ WHERE workflow_definition_id = definition_id;
diff --git a/Flow/db_patches/patch-add_workflow_type.sqlite.sql b/Flow/db_patches/patch-add_workflow_type.sqlite.sql
new file mode 100644
index 00000000..fe8cbcbe
--- /dev/null
+++ b/Flow/db_patches/patch-add_workflow_type.sqlite.sql
@@ -0,0 +1,10 @@
+
+ALTER TABLE /*_*/flow_workflow ADD workflow_type varbinary(16);
+
+-- this is very inefficient, but sqlite will not allow an update
+-- against multiple tables.
+
+UPDATE /*_*/flow_workflow
+ SET workflow_type = ( SELECT definition_type
+ FROM /*_*/flow_definition
+ WHERE workflow_definition_id = definition_id );
diff --git a/Flow/db_patches/patch-censor_to_suppress.sql b/Flow/db_patches/patch-censor_to_suppress.sql
new file mode 100644
index 00000000..8bfd31f8
--- /dev/null
+++ b/Flow/db_patches/patch-censor_to_suppress.sql
@@ -0,0 +1,12 @@
+-- updates suppression terminology, which used to be called 'censor'
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'suppress-post' WHERE rev_change_type = 'censor-post' AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'suppress-topic' WHERE rev_change_type = 'censor-topic' AND rev_type = 'post';
+
+UPDATE /*_*/logging SET log_action = 'flow-suppress-post' WHERE log_action = 'flow-censor-post' AND log_type = 'suppress';
+UPDATE /*_*/logging SET log_action = 'flow-suppress-topic' WHERE log_action = 'flow-censor-topic' AND log_type = 'suppress';
+
+-- recentchanges: this query is expensive & the code has fallbacks in place
+-- don't execute unless you only have few Flow data
+UPDATE /*_*/recentchanges SET rc_params = REPLACE(rc_params, 's:11:"censor-post"', 's:13:"suppress-post"') WHERE (rc_type = 142 OR rc_source = 'flow') AND rc_params LIKE '%s:11:"censor-post"%';
+UPDATE /*_*/recentchanges SET rc_params = REPLACE(rc_params, 's:12:"censor-topic"', 's:14:"suppress-topic"') WHERE (rc_type = 142 OR rc_source = 'flow') AND rc_params LIKE '%s:12:"censor-topic"%';
diff --git a/Flow/db_patches/patch-default_null_workflow_user.sql b/Flow/db_patches/patch-default_null_workflow_user.sql
new file mode 100644
index 00000000..9006d277
--- /dev/null
+++ b/Flow/db_patches/patch-default_null_workflow_user.sql
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/flow_workflow
+ CHANGE workflow_user_id workflow_user_id bigint unsigned default null,
+ CHANGE workflow_user_wiki workflow_user_wiki varchar(32) binary default null;
+
diff --git a/Flow/db_patches/patch-default_null_workflow_user.sqlite.sql b/Flow/db_patches/patch-default_null_workflow_user.sqlite.sql
new file mode 100644
index 00000000..598b59d8
--- /dev/null
+++ b/Flow/db_patches/patch-default_null_workflow_user.sqlite.sql
@@ -0,0 +1,30 @@
+ALTER TABLE /*_*/flow_workflow RENAME TO /*_*/temp_flow_workflow_default_null;
+
+CREATE TABLE /*_*/flow_workflow (
+ workflow_id binary(11) not null,
+ workflow_wiki varchar(16) binary not null,
+ workflow_namespace int not null,
+ workflow_page_id int unsigned not null,
+ workflow_title_text varchar(255) binary not null,
+ workflow_name varchar(255) binary not null,
+ workflow_last_update_timestamp binary(14) not null,
+ -- TODO: check what the new global user ids need for storage
+ workflow_user_id bigint unsigned default null,
+ workflow_user_ip varbinary(39) default null,
+ workflow_user_wiki varchar(32) binary default null,
+ -- TODO: is this usefull 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,
+ PRIMARY KEY (workflow_id)
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/flow_workflow
+ (workflow_id, workflow_wiki, workflow_namespace, workflow_page_id, workflow_title_text, workflow_name, workflow_last_update_timestamp, workflow_user_id, workflow_user_ip, workflow_user_wiki, workflow_lock_state, workflow_type )
+ SELECT workflow_id, workflow_wiki, workflow_namespace, workflow_page_id, workflow_title_text, workflow_name, workflow_last_update_timestamp, workflow_user_id, workflow_user_ip, workflow_user_wiki, workflow_lock_state, workflow_type
+ FROM /*_*/temp_flow_workflow_default_null;
+
+DROP TABLE /*_*/temp_flow_workflow_default_null;
+
+CREATE INDEX /*i*/flow_workflow_lookup ON /*_*/flow_workflow (workflow_wiki, workflow_namespace, workflow_title_text);
+
diff --git a/Flow/db_patches/patch-drop_definition.sql b/Flow/db_patches/patch-drop_definition.sql
new file mode 100644
index 00000000..cef82f25
--- /dev/null
+++ b/Flow/db_patches/patch-drop_definition.sql
@@ -0,0 +1,3 @@
+DROP TABLE /*_*/flow_definition;
+ALTER TABLE /*_*/flow_workflow
+ DROP workflow_definition_id;
diff --git a/Flow/db_patches/patch-drop_workflow_user.sql b/Flow/db_patches/patch-drop_workflow_user.sql
new file mode 100644
index 00000000..85796f9c
--- /dev/null
+++ b/Flow/db_patches/patch-drop_workflow_user.sql
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/flow_workflow
+ DROP workflow_user_id,
+ DROP workflow_user_ip,
+ DROP workflow_user_wiki;
diff --git a/Flow/db_patches/patch-flow_tree_idx_fix.sql b/Flow/db_patches/patch-flow_tree_idx_fix.sql
new file mode 100644
index 00000000..4447ca3f
--- /dev/null
+++ b/Flow/db_patches/patch-flow_tree_idx_fix.sql
@@ -0,0 +1,4 @@
+
+DROP INDEX /*i*/flow_tree_descendant_id_revisions ON /*_*/flow_tree_revision;
+CREATE INDEX /*i*/flow_tree_descendant_rev_id ON /*_*/flow_tree_revision ( tree_rev_descendant_id, tree_rev_id );
+
diff --git a/Flow/db_patches/patch-increase_width_wiki_fields.sql b/Flow/db_patches/patch-increase_width_wiki_fields.sql
new file mode 100644
index 00000000..9b0d499e
--- /dev/null
+++ b/Flow/db_patches/patch-increase_width_wiki_fields.sql
@@ -0,0 +1,11 @@
+-- This patch doesn't need to be SQLite compatible (or re-implemented
+-- for SQLite) since SQLite doesn't care about column widths anyway.
+ALTER TABLE /*_*/flow_workflow MODIFY workflow_wiki varchar(64) binary not null;
+
+ALTER TABLE /*_*/flow_subscription MODIFY subscription_user_wiki varchar(64) binary not null;
+
+ALTER TABLE /*_*/flow_tree_revision MODIFY tree_orig_user_wiki varchar(64) binary not null;
+
+ALTER TABLE /*_*/flow_revision MODIFY rev_user_wiki varchar(64) binary not null,
+ MODIFY rev_mod_user_wiki varchar(64) binary default null,
+ MODIFY rev_edit_user_wiki varchar(64) binary default null;
diff --git a/Flow/db_patches/patch-moderation_reason.sql b/Flow/db_patches/patch-moderation_reason.sql
new file mode 100644
index 00000000..8bf2a243
--- /dev/null
+++ b/Flow/db_patches/patch-moderation_reason.sql
@@ -0,0 +1,3 @@
+-- Patch to add the "moderated reason" field to revision table
+
+ALTER TABLE /*_*/flow_revision ADD COLUMN rev_mod_reason varchar(255) binary; \ No newline at end of file
diff --git a/Flow/db_patches/patch-rc_source.sql b/Flow/db_patches/patch-rc_source.sql
new file mode 100644
index 00000000..0f9c2deb
--- /dev/null
+++ b/Flow/db_patches/patch-rc_source.sql
@@ -0,0 +1,4 @@
+-- Updates Flow's recentchanges entries to new rc_source column
+-- values for rc_source & rc_type are respectively RC_FLOW &
+-- Flow\Data\RecentChanges::SRC_FLOW, as defined in Flow.php
+UPDATE /*_*/recentchanges SET rc_source = "flow" WHERE rc_type = 142;
diff --git a/Flow/db_patches/patch-remove_unique_ref_indices.sql b/Flow/db_patches/patch-remove_unique_ref_indices.sql
new file mode 100644
index 00000000..7a0cc315
--- /dev/null
+++ b/Flow/db_patches/patch-remove_unique_ref_indices.sql
@@ -0,0 +1,15 @@
+-- drop unique constraint & recreate index
+DROP INDEX /*i*/flow_wiki_ref_pk ON /*_*/flow_wiki_ref;
+DROP INDEX /*i*/flow_wiki_ref_revision ON /*_*/flow_wiki_ref;
+
+CREATE INDEX /*i*/flow_wiki_ref_idx ON /*_*/flow_wiki_ref ( ref_src_namespace, ref_src_title, ref_type, ref_target_namespace, ref_target_title, ref_src_object_type, ref_src_object_id );
+CREATE INDEX /*i*/flow_wiki_ref_revision ON /*_*/flow_wiki_ref ( ref_src_namespace, ref_src_title, ref_src_object_type, ref_src_object_id, ref_type, ref_target_namespace, ref_target_title );
+
+-- drop unique constraint, change url column to blob & recreate index
+DROP INDEX /*i*/flow_ext_ref_pk ON /*_*/flow_ext_ref;
+DROP INDEX /*i*/flow_ext_ref_revision ON /*_*/flow_ext_ref;
+
+ALTER TABLE /*_*/flow_ext_ref CHANGE ref_target ref_target BLOB;
+
+CREATE INDEX /*i*/flow_ext_ref_idx ON /*_*/flow_ext_ref ( ref_src_namespace, ref_src_title, ref_type, ref_target(255), ref_src_object_type, ref_src_object_id );
+CREATE INDEX /*i*/flow_ext_ref_revision ON /*_*/flow_ext_ref ( ref_src_namespace, ref_src_title, ref_src_object_type, ref_src_object_id, ref_type, ref_target(255) );
diff --git a/Flow/db_patches/patch-remove_usernames.sql b/Flow/db_patches/patch-remove_usernames.sql
new file mode 100644
index 00000000..fd2833ee
--- /dev/null
+++ b/Flow/db_patches/patch-remove_usernames.sql
@@ -0,0 +1,12 @@
+
+ALTER TABLE /*_*/flow_tree_revision ADD tree_orig_user_ip varbinary(39) default null;
+UPDATE /*_*/flow_tree_revision SET tree_orig_user_ip = null WHERE tree_orig_user_id != 0;
+
+ALTER TABLE /*_*/flow_revision
+ ADD rev_user_ip varbinary(39) default null,
+ ADD rev_mod_user_ip varbinary(39) default null,
+ ADD rev_edit_user_ip varbinary(39) default null;
+
+UPDATE /*_*/flow_revision SET rev_user_ip = null WHERE rev_user_id != 0;
+UPDATE /*_*/flow_revision SET rev_mod_user_ip = null WHERE rev_mod_user_id != 0;
+UPDATE /*_*/flow_revision SET rev_edit_user_ip = null WHERE rev_edit_user_id != 0;
diff --git a/Flow/db_patches/patch-remove_usernames_2.sql b/Flow/db_patches/patch-remove_usernames_2.sql
new file mode 100644
index 00000000..e3f3f1e2
--- /dev/null
+++ b/Flow/db_patches/patch-remove_usernames_2.sql
@@ -0,0 +1,8 @@
+ALTER TABLE /*_*/flow_workflow DROP workflow_user_text;
+
+ALTER TABLE /*_*/flow_tree_revision DROP tree_orig_user_text;
+
+ALTER TABLE /*_*/flow_revision
+ DROP rev_user_text,
+ DROP rev_mod_user_text,
+ DROP rev_edit_user_text;
diff --git a/Flow/db_patches/patch-rev_change_type.sql b/Flow/db_patches/patch-rev_change_type.sql
new file mode 100644
index 00000000..63cd28f9
--- /dev/null
+++ b/Flow/db_patches/patch-rev_change_type.sql
@@ -0,0 +1,2 @@
+-- Changes rev_comment to rev_change_type
+ALTER TABLE /*_*/flow_revision CHANGE rev_comment rev_change_type varbinary(255) null;
diff --git a/Flow/db_patches/patch-rev_change_type.sqlite.sql b/Flow/db_patches/patch-rev_change_type.sqlite.sql
new file mode 100644
index 00000000..1352e7aa
--- /dev/null
+++ b/Flow/db_patches/patch-rev_change_type.sqlite.sql
@@ -0,0 +1,50 @@
+
+
+ALTER TABLE /*_*/flow_revision RENAME TO /*_*/temp_flow_revision_change_type;
+
+CREATE TABLE /*_*/flow_revision (
+ -- UID::newTimestampedUID128()
+ rev_id binary(16) not null,
+ -- What kind of revision is this: tree/summary/etc.
+ rev_type varchar(16) binary not null,
+ -- user id creating the revision
+ rev_user_id bigint unsigned not null,
+ -- name of user creating the revision, or ip address if anon
+ -- TODO: global user logins will obviate the need for this, but a round trip
+ -- will be needed to map from rev_user_id -> user name
+ rev_user_text varchar(255) binary not null default '',
+ -- rev_id of parent or null if no previous revision
+ rev_parent_id binary(16),
+ -- comma separated set of ascii flags.
+ rev_flags tinyblob not null,
+ -- content of the revision
+ rev_content mediumblob not null,
+ -- the type of change that was made. MW message key.
+ -- formerly rev_comment
+ rev_change_type varbinary(255) null,
+ -- current moderation state
+ rev_mod_state varchar(32) binary not null,
+ -- moderated by who?
+ rev_mod_user_id bigint unsigned,
+ rev_mod_user_text varchar(255) binary,
+ rev_mod_timestamp varchar(14) binary,
+
+ -- track who made the most recent content edit
+ rev_last_edit_id binary(16) null,
+ rev_edit_user_id bigint unsigned,
+ rev_edit_user_text varchar(255) binary,
+
+ PRIMARY KEY (rev_id)
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/flow_revision
+ (rev_id, rev_type, rev_user_id, rev_user_text, rev_parent_id, rev_flags, rev_content, rev_change_type, rev_mod_state, rev_mod_user_id, rev_mod_user_text, rev_mod_timestamp, rev_last_edit_id, rev_edit_user_id, rev_edit_user_text )
+SELECT
+ rev_id, rev_type, rev_user_id, rev_user_text, rev_parent_id, rev_flags, rev_content, rev_comment, rev_mod_state, rev_mod_user_id, rev_mod_user_text, rev_mod_timestamp, rev_last_edit_id, rev_edit_user_id, rev_edit_user_text
+FROM
+ /*_*/temp_flow_revision_change_type;
+
+DROP TABLE /*_*/temp_flow_revision_change_type;
+
+CREATE UNIQUE INDEX /*i*/flow_revision_unique_parent ON
+ /*_*/flow_revision (rev_parent_id);
diff --git a/Flow/db_patches/patch-rev_change_type_update.sql b/Flow/db_patches/patch-rev_change_type_update.sql
new file mode 100644
index 00000000..a40ed7a6
--- /dev/null
+++ b/Flow/db_patches/patch-rev_change_type_update.sql
@@ -0,0 +1,14 @@
+-- Updates older change_type values to match with action names
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-title' WHERE rev_change_type IN('flow-rev-message-edit-title', 'flow-edit-title') AND rev_type = 'post';
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'new-post' WHERE rev_change_type IN('flow-rev-message-new-post', 'flow-new-post') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-post' WHERE rev_change_type IN('flow-rev-message-edit-post', 'flow-edit-post') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'reply' WHERE rev_change_type IN('flow-rev-message-reply', 'flow-reply') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'restore-post' WHERE rev_change_type IN('flow-rev-message-restored-post', 'flow-post-restored') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'hide-post' WHERE rev_change_type IN('flow-rev-message-hid-post', 'flow-post-hidden') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'delete-post' WHERE rev_change_type IN('flow-rev-message-deleted-post', 'flow-post-deleted') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'censor-post' WHERE rev_change_type IN('flow-rev-message-censored-post', 'flow-post-censored') AND rev_type = 'post';
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-header' WHERE rev_change_type IN ('flow-rev-message-edit-header', 'flow-edit-summary') AND rev_type = 'header';
+UPDATE /*_*/flow_revision SET rev_change_type = 'create-header' WHERE rev_change_type IS NULL OR rev_change_type IN ('flow-rev-message-create-header', 'flow-create-summary', 'flow-create-header') AND rev_type = 'header';
diff --git a/Flow/db_patches/patch-rev_type_id.sql b/Flow/db_patches/patch-rev_type_id.sql
new file mode 100644
index 00000000..b569932d
--- /dev/null
+++ b/Flow/db_patches/patch-rev_type_id.sql
@@ -0,0 +1,4 @@
+
+ALTER TABLE /*_*/flow_revision ADD rev_type_id binary(11) not null default '';
+
+CREATE INDEX /*i*/flow_revision_type_id ON /*_*/flow_revision (rev_type, rev_type_id);
diff --git a/Flow/db_patches/patch-revision_last_editor.sql b/Flow/db_patches/patch-revision_last_editor.sql
new file mode 100644
index 00000000..adf430e0
--- /dev/null
+++ b/Flow/db_patches/patch-revision_last_editor.sql
@@ -0,0 +1,7 @@
+-- Patch to add infomation about the last content edit to flow revisions
+ALTER TABLE /*_*/flow_revision
+ ADD rev_last_edit_id binary(16) null,
+ ADD rev_edit_user_id bigint unsigned,
+ ADD rev_edit_user_text varchar(255) binary,
+ CHANGE rev_user_id rev_user_id bigint unsigned not null;
+
diff --git a/Flow/db_patches/patch-revision_user_idx.sql b/Flow/db_patches/patch-revision_user_idx.sql
new file mode 100644
index 00000000..1330705e
--- /dev/null
+++ b/Flow/db_patches/patch-revision_user_idx.sql
@@ -0,0 +1,2 @@
+-- Special:Contributions can do queries based on user id/ip
+CREATE INDEX /*i*/flow_revision_user ON /*_*/flow_revision (rev_user_id, rev_user_ip, rev_user_wiki);
diff --git a/Flow/db_patches/patch-revision_user_ip.sql b/Flow/db_patches/patch-revision_user_ip.sql
new file mode 100644
index 00000000..02a5f27e
--- /dev/null
+++ b/Flow/db_patches/patch-revision_user_ip.sql
@@ -0,0 +1,3 @@
+-- we used to store the username in there, when user was logged in
+-- now we need it blank to reliably query for Special:Contributions
+UPDATE /*_*/flow_revision SET rev_user_ip = NULL WHERE rev_user_id != 0;
diff --git a/Flow/db_patches/patch-subscription_user_id.sql b/Flow/db_patches/patch-subscription_user_id.sql
new file mode 100644
index 00000000..908fb450
--- /dev/null
+++ b/Flow/db_patches/patch-subscription_user_id.sql
@@ -0,0 +1,3 @@
+-- Patch to add infomation about the last content edit to flow revisions
+ALTER TABLE /*_*/flow_subscription CHANGE subscription_user_id subscription_user_id bigint unsigned not null;
+
diff --git a/Flow/db_patches/patch-summary2header.sql b/Flow/db_patches/patch-summary2header.sql
new file mode 100644
index 00000000..cff001d6
--- /dev/null
+++ b/Flow/db_patches/patch-summary2header.sql
@@ -0,0 +1,9 @@
+-- Renames "summaries" to "headers"
+ALTER TABLE /*_*/flow_summary_revision
+ RENAME TO flow_header_revision,
+ DROP PRIMARY KEY,
+ CHANGE COLUMN summary_workflow_id header_workflow_id binary(16) not null,
+ CHANGE COLUMN summary_rev_id header_rev_id binary(16) not null,
+ ADD PRIMARY KEY ( header_workflow_id, header_rev_id );
+
+UPDATE /*_*/flow_revision SET rev_type='header' WHERE rev_type='summary'; \ No newline at end of file
diff --git a/Flow/db_patches/patch-summary2header.sqlite.sql b/Flow/db_patches/patch-summary2header.sqlite.sql
new file mode 100644
index 00000000..806effb3
--- /dev/null
+++ b/Flow/db_patches/patch-summary2header.sqlite.sql
@@ -0,0 +1,21 @@
+-- Sqlites alter table statement can NOT change existing columns. The only
+-- option since we want to rename the table and its columns is to recreate
+-- the table and copy the data over
+
+
+CREATE TABLE /*_*/flow_header_revision (
+ header_workflow_id binary(16) not null,
+ header_rev_id binary(16) not null,
+ PRIMARY KEY (header_workflow_id, header_rev_id)
+);
+
+INSERT INTO /*_*/flow_header_revision
+ (header_workflow_id, header_rev_id)
+SELECT
+ summary_workflow_id, summary_rev_id
+FROM
+ /*_*/flow_summary_revision;
+
+DROP TABLE /*_*/flow_summary_revision;
+
+UPDATE /*_*/flow_revision SET rev_type='header' WHERE rev_type='summary';
diff --git a/Flow/db_patches/patch-topic_list_topic_id_idx.sql b/Flow/db_patches/patch-topic_list_topic_id_idx.sql
new file mode 100644
index 00000000..2d0d8df2
--- /dev/null
+++ b/Flow/db_patches/patch-topic_list_topic_id_idx.sql
@@ -0,0 +1 @@
+CREATE INDEX /*i*/flow_topic_list_topic_id ON /*_*/flow_topic_list (topic_id);
diff --git a/Flow/db_patches/patch-tree_orig_create_time.sql b/Flow/db_patches/patch-tree_orig_create_time.sql
new file mode 100644
index 00000000..605911c2
--- /dev/null
+++ b/Flow/db_patches/patch-tree_orig_create_time.sql
@@ -0,0 +1,2 @@
+ALTER TABLE /*_*/flow_tree_revision
+ DROP COLUMN tree_orig_create_time;
diff --git a/Flow/db_patches/patch-workflow_lookup_idx.sql b/Flow/db_patches/patch-workflow_lookup_idx.sql
new file mode 100644
index 00000000..4cbe6459
--- /dev/null
+++ b/Flow/db_patches/patch-workflow_lookup_idx.sql
@@ -0,0 +1 @@
+CREATE INDEX /*i*/flow_workflow_lookup ON /*_*/flow_workflow (workflow_wiki, workflow_namespace, workflow_title_text);