We define two config parameters that hold the source version in “protected/config/”. One is the DVS reference, and the other one is human-readable. So from Yii they can be read with Yii::app()->params['version']. Then we could detect if the DB is not synchronized with the source code.
But we don’t do it because DB migration are always automatically applied. We add a git/hg hook so that each update modifies the config file (with the DVCS ref) and applies the migration. The reference is inserted with a one-liner perl -i -pe 's/.../.../' ... but it could be done with a PHP script.