Fix some issue and add log when upgrade database