I've done something similar to this by creating an endpoint on my server that returns a JSON object containing the current version number.
When my app loads it makes a request to the end point and compares the JSON return to a localStorage variable in the device.
Then (like you suggested above) if the JSON return is greater than the localStorage variable, the database is updated and then the localStorage variable is updated to the value of the current JSON return.
Example:
function updateDatabase () {
$.ajax({
url: 'http://your_web_site.tdl/databaseversion/',
cache: false,
type: 'GET',
success: function(result, status, xhr) {
var currentVersion = result.version;
if(!window.localStorage.getItem('localVersion') || window.localStorage.getItem('localVersion') < currentVersion) {
//UPDATE DATABASE CODE HERE
window.localStorage.setItem('localVersion',currentVersion);
}
else{
//NO NEED TO UPDATE
}
},
error: function() {
//CANNOT GET CURRENT VERSION FROM SERVER
}
});
}
This assumes that your server will return the JSON:
{ version: 'X' }