Handle database upgrade for MSIM

Change-Id: I7c37252900bf0a61fdd64b301ab5b852711a42e5
Missing commas before sub_id in sql queries

Change-Id: I74abc23535f6a008c91b15343e9558711a515c44