aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/sqlite
diff options
context:
space:
mode:
authorEddie Greiner-Petter <git@eddie-sh.de>2017-05-08 21:31:54 +0200
committerKrinkle <krinklemail@gmail.com>2018-03-26 23:51:40 +0000
commit27c76fa4ae07b6a1404bad269698d1af2679cc43 (patch)
tree895bf365613ff7749f33335591470e774cc77ba3 /maintenance/sqlite
parentabeca9ac48415828428284816d76dee347e680ea (diff)
downloadmediawikicore-27c76fa4ae07b6a1404bad269698d1af2679cc43.tar.gz
mediawikicore-27c76fa4ae07b6a1404bad269698d1af2679cc43.zip
Overhaul site_stats table
The site stats table holds a bunch of metric fields, two of which are of data type "bigint unsigned", 3 are "bigint" (signed) and one is int (signed). Also the default values differ widely: It is 0 on the "unsigned" fields and the "int" field, but -1 on the three others. This patch makes all of this more consistent: Set all fields (except the ss_row_id, which isn't changed) data type to "bigint unsigned". Also set NULL as the default value for all those fields. Obviously -1 isn't a possible default value any more. Also, 0 can easily be mistaken for a real value (e.g. ss_active_users=0 --> "there is nobody active on this wiki"). NULL, by it's definition, is the value of choice for a value to insert into fields of which we don't know a correct value. The respective patch files were tested locally against MySql, Sqlite, Postgres and SQL Server 2016. Neither oracle nor the upgrade with update.php was tested. Bug: T56888 Change-Id: I7d42aae434852a56b6f8dd559d8a5f3bce416021
Diffstat (limited to 'maintenance/sqlite')
-rw-r--r--maintenance/sqlite/archives/patch-site_stats-modify.sql35
1 files changed, 35 insertions, 0 deletions
diff --git a/maintenance/sqlite/archives/patch-site_stats-modify.sql b/maintenance/sqlite/archives/patch-site_stats-modify.sql
new file mode 100644
index 000000000000..8d267a62f005
--- /dev/null
+++ b/maintenance/sqlite/archives/patch-site_stats-modify.sql
@@ -0,0 +1,35 @@
+DROP TABLE IF EXISTS /*_*/site_stats_tmp;
+
+-- Create the temporary table. The following part
+-- is copied & pasted from the changed tables.sql
+-- file besides having an other table name.
+CREATE TABLE /*_*/site_stats_tmp (
+ ss_row_id int unsigned NOT NULL PRIMARY KEY,
+ ss_total_edits bigint unsigned default NULL,
+ ss_good_articles bigint unsigned default NULL,
+ ss_total_pages bigint unsigned default NULL,
+ ss_users bigint unsigned default NULL,
+ ss_active_users bigint unsigned default NULL,
+ ss_images bigint unsigned default NULL
+) /*$wgDBTableOptions*/;
+
+-- Move the data from the old to the new table
+INSERT OR IGNORE INTO /*_*/site_stats_tmp (
+ ss_row_id,
+ ss_total_edits,
+ ss_good_articles,
+ ss_total_pages,
+ ss_active_users,
+ ss_images
+) SELECT
+ ss_row_id,
+ ss_total_edits,
+ ss_good_articles,
+ ss_total_pages,
+ ss_active_users,
+ ss_images
+FROM /*_*/site_stats;
+
+DROP TABLE /*_*/site_stats;
+
+ALTER TABLE /*_*/site_stats_tmp RENAME TO /*_*/site_stats;