In order to trigger a "upgradeneeded" event you need to request the database with version higher than the current version - otherwise the event won't be triggered.
function createTable(dbName, dbversion, tableName) {
var request = indexedDB.open(dbName, dbversion);
request.onupgrade...