Combined changes from pull requests pending in Automattic repository by Orio91 and sreenadh

To be compatible with mysql, included change from sreenadh, and modified database upgrade part to only modify revision and add repository column, Orio91 had some SQLlite only changes, which i didn't figure out what they was meant for.

Multi repository is now supported, but only if the default repository is set as an alias to normally added repository (slight glitch, but can be avoided by changing the setup of repositories without loosing any info or interlinking, will expand in a issue).

What is not included is changes from Orio91 regarding the permission change from TRAC_ADMIN to CODE_COMMENT as it was not neccessary.