While upgrading the database scheme from 3.1 to 4.0, the migration throws an exception while trying to modify the primary keys of the xwikistatsdoc table. The two rows which seem to cause the problem look like the following (XWS_NAME was modified due to confidentiality issues, but they both have the same name, the XWS_Id shown is the one prior to upgrade):
XWS_ID XWS_NUMBER XWS_NAME XWS_CLASSNAME XWS_ACTION XWS_PAGE_VIEWS XWS_UNIQUE_VISITORS XWS_PERIOD XWS_VISITS
-899455387 -364773911 X.Y download 41 0 201103 0
-899455388 -364773910 X.Y download 9 0 201104 0
In my case both rows receive a new primary ID of -7231869940862556120.
For the moment I deleted all entries in xwikistatsdoc in order to upgrade XWiki.