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
35 lines
967 B
SQL
35 lines
967 B
SQL
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;
|