wiki.techinc.nl/maintenance/archives/patch-site_stats-modify.sql
Eddie Greiner-Petter 27c76fa4ae 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
2018-03-26 23:51:40 +00:00

7 lines
340 B
SQL

ALTER TABLE /*_*/site_stats
ALTER ss_total_edits SET DEFAULT NULL,
ALTER ss_good_articles SET DEFAULT NULL,
MODIFY COLUMN ss_total_pages bigint unsigned DEFAULT NULL,
MODIFY COLUMN ss_users bigint unsigned DEFAULT NULL,
MODIFY COLUMN ss_active_users bigint unsigned DEFAULT NULL,
MODIFY COLUMN ss_images bigint unsigned DEFAULT NULL;