Rjain has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78373
Change subject: Added the db_patch files for renaming rev_id and user_id column
......................................................................
Added the db_patch files for renaming rev_id and user_id column
Change-Id: Ibf45c14312ecc191c629ea7fb532b6e93c555063
---
M Annotator.hooks.php
M sql/annotator.sql
A sql/db_patches/patch-rev_id-rename.sql
A sql/db_patches/patch-rev_id-rename.sqlite.sql
A sql/db_patches/patch-user_id-rename.sql
A sql/db_patches/patch-user_id-rename.sqlite.sql
6 files changed, 60 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Annotator
refs/changes/73/78373/1
diff --git a/Annotator.hooks.php b/Annotator.hooks.php
index 1364833..d559d8b 100755
--- a/Annotator.hooks.php
+++ b/Annotator.hooks.php
@@ -20,6 +20,15 @@
'annotator_rev_id',
dirname( __FILE__ ) . '/sql/index_rev_id.sql'
);
+
+ if( $updater->getDB()->getType() === 'sqlite' ) {
+ $updater->modifyExtensionField( 'annotator', 'user_id',
"$dir/sql/db_patches/patch-user_id-rename.sqlite.sql" );
+ $updater->modifyExtensionField( 'annotator', 'rev_id',
"$dir/sql/db_patches/patch-rev_id-rename.sqlite.sql" );
+ }
+ else {
+ $updater->modifyExtensionField( 'annotator', 'user_id',
"$dir/sql/db_patches/patch-user_id-rename.sql" );
+ $updater->modifyExtensionField( 'annotator', 'rev_id',
"$dir/sql/db_patches/patch-rev_id-rename.sql" );
+ }
return true;
}
/*adds the annotator js and css
diff --git a/sql/annotator.sql b/sql/annotator.sql
index 47ee692..34f713e 100644
--- a/sql/annotator.sql
+++ b/sql/annotator.sql
@@ -5,7 +5,7 @@
CREATE TABLE IF NOT EXISTS /*_*/annotator (
annotation_id int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
annotation_json text NOT NULL,
- rev_id int(10) unsigned NOT NULL,
+ annotation_rev_id int(10) unsigned NOT NULL,
annotation_user_id int(10) unsigned NOT NULL
) /*$wgDBTableOptions*/;
diff --git a/sql/db_patches/patch-rev_id-rename.sql
b/sql/db_patches/patch-rev_id-rename.sql
new file mode 100644
index 0000000..1894dab
--- /dev/null
+++ b/sql/db_patches/patch-rev_id-rename.sql
@@ -0,0 +1 @@
+ALTER TABLE annotator CHANGE COLUMN rev_id annotation_rev_id int(10) unsigned
NOT NULL;
\ No newline at end of file
diff --git a/sql/db_patches/patch-rev_id-rename.sqlite.sql
b/sql/db_patches/patch-rev_id-rename.sqlite.sql
new file mode 100644
index 0000000..058299e
--- /dev/null
+++ b/sql/db_patches/patch-rev_id-rename.sqlite.sql
@@ -0,0 +1,24 @@
+ALTER TABLE annotator CHANGE COLUMN rev_id annotation_rev_id int(10) unsigned
NOT NULL;
+
+-- Rename current table to temporary name
+ALTER TABLE /*_*/annotator RENAME TO /*_*/temp_annotator_rename_rev_id;
+
+CREATE TABLE IF NOT EXISTS /*_*/annotator (
+ annotation_id int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ annotation_json text NOT NULL,
+ annotation_rev_id int(10) unsigned NOT NULL,
+ annotation_user_id int(10) unsigned NOT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/echo_event
+ ( annotation_id, annotation_json, annotation_rev_id, annotation_user_id
)
+SELECT
+ annotation_id, annotation_json, annotation_rev_id, annotation_user_id
+FROM
+ /*_*/temp_annotator_rename_rev_id;
+
+--Drop the original table--
+DROP TABLE /*_*/temp_annotator_rename_rev_id;
+
+--recreate indexes--
+CREATE INDEX /*i*/annotator_rev_id ON /*_*/annotator (annotation_rev_id);
\ No newline at end of file
diff --git a/sql/db_patches/patch-user_id-rename.sql
b/sql/db_patches/patch-user_id-rename.sql
new file mode 100644
index 0000000..5445c46
--- /dev/null
+++ b/sql/db_patches/patch-user_id-rename.sql
@@ -0,0 +1 @@
+ALTER TABLE annotator CHANGE COLUMN user_id annotation_user_id int(10)
unsigned NOT NULL;
\ No newline at end of file
diff --git a/sql/db_patches/patch-user_id-rename.sqlite.sql
b/sql/db_patches/patch-user_id-rename.sqlite.sql
new file mode 100644
index 0000000..91d448c
--- /dev/null
+++ b/sql/db_patches/patch-user_id-rename.sqlite.sql
@@ -0,0 +1,24 @@
+ALTER TABLE annotator CHANGE COLUMN user_id annotation_user_id int(10)
unsigned NOT NULL;
+
+-- Rename current table to temporary name
+ALTER TABLE /*_*/annotator RENAME TO /*_*/temp_annotator_rename_user_id;
+
+CREATE TABLE IF NOT EXISTS /*_*/annotator (
+ annotation_id int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ annotation_json text NOT NULL,
+ annotation_rev_id int(10) unsigned NOT NULL,
+ annotation_user_id int(10) unsigned NOT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/echo_event
+ ( annotation_id, annotation_json, annotation_rev_id, annotation_user_id
)
+SELECT
+ annotation_id, annotation_json, annotation_rev_id, annotation_user_id
+FROM
+ /*_*/temp_annotator_rename_user_id;
+
+--Drop the original table--
+DROP TABLE /*_*/temp_annotator_rename_user_id;
+
+--recreate indexes--
+CREATE INDEX /*i*/annotator_rev_id ON /*_*/annotator (annotation_rev_id);
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/78373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf45c14312ecc191c629ea7fb532b6e93c555063
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Annotator
Gerrit-Branch: master
Gerrit-Owner: Rjain <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits