Generic renaming.

@param outdatedDBEntry the outdated db entry where the upgrade should be applied to.
@param dbSnapshot      all entries of the current database which may are partially upgraded.

@return the updated value.
173268
@Override
    public JsonObject upgrade(final JsonObject outdatedDBEntry, Map<File, JsonObject> dbSnapshot) {
        return rename(outdatedDBEntry, newName, path);
    }
1007976
function(db, trans, is_caller_setversion) {

    var action = is_caller_setversion ? 'changing' : 'upgrading';
    goog.log.finer(me.logger, action + ' version to ' + db.version +
        ' from ' + old_version);

    // create store that we don't have previously
    for (var i = 0; i < schema.stores.length; i++) {
      // this is sync process.
      me.update_store_(db, trans, schema.stores[i]);
    }

    // delete stores
    var storeNames = /** @type {DOMStringList} */ (db.objectStoreNames);
    for (var n = storeNames.length, i = 0; i < n; i++) {
      if (!schema.hasStore(storeNames[i])) {
        db.deleteObjectStore(storeNames[i]);
        goog.log.finer(me.logger, 'store: ' + storeNames[i] + ' deleted.');
      }
    }
  }
1074507
@Override
  public CompletableFuture<Void> restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot) {
    CompletableFuture<Void> future = new CompletableFuture<>();
    listSnapshots(Pattern.compile(snapshotName)).whenComplete(
      (snapshotDescriptions, err) -> {
        if (err != null) {
          future.completeExceptionally(err);
          return;
        }
        final TableName tableName = snapshotExists(snapshotName,snapshotDescriptions);
        if (tableName == null) {
          future.completeExceptionally(new RestoreSnapshotException(
              "Unable to find the table name for snapshot=" + snapshotName));
          return;
        }
        tableExists(tableName)
            .whenComplete((exists, err2) -> {
              if (err2 != null) {
                future.completeExceptionally(err2);
              } else if (!exists) {
                // if table does not exist, then just clone snapshot into new table.
                completeConditionalOnFuture(future,cloneSnapshot(snapshotName, tableName));
              } else {
               isTableDisabled(tableName).whenComplete((disabled, err4) -> {
                  if (err4 != null) {
                    future.completeExceptionally(err4);
                  } else if (!disabled) {
                    future.completeExceptionally(new TableNotDisabledException(tableName));
                  } else {
                    completeConditionalOnFuture(future,
                      restoreSnapshot(snapshotName,takeFailSafeSnapshot));
                  }
                });
            }
          });
        });
    return future;
  }
773517
public void saveOldProperties(Map<String,String> oldProperties, Record record)
    {
        this.saveOldProperty(oldProperties, record.getDatabaseName() + BaseDatabase.DBSHARED_PARAM_SUFFIX);
        this.saveOldProperty(oldProperties, record.getDatabaseName() + BaseDatabase.DBUSER_PARAM_SUFFIX);
        this.saveOldProperty(oldProperties, DBConstants.DB_USER_PREFIX);
        this.saveOldProperty(oldProperties, DBConstants.SYSTEM_NAME);
        this.saveOldProperty(oldProperties, DBParams.LANGUAGE);
    }
390684
private Versioned<Collection<byte[]>> toVersioned(
      MapEntryValues value) {
    return value == null
        ? new Versioned<>(Collections.emptyList(), -1)
        : new Versioned<>(value.values(), value.version());
  }
768440
public static void doMetaUpdateVersionsOnStores(AdminClient adminClient,
                                                        List<StoreDefinition> oldStoreDefs,
                                                        List<StoreDefinition> newStoreDefs) {
            Set<String> storeNamesUnion = new HashSet<String>();
            Map<String, StoreDefinition> oldStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            Map<String, StoreDefinition> newStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            List<String> storesChanged = new ArrayList<String>();
            for(StoreDefinition storeDef: oldStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                oldStoreDefinitionMap.put(storeName, storeDef);
            }
            for(StoreDefinition storeDef: newStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                newStoreDefinitionMap.put(storeName, storeDef);
            }
            for(String storeName: storeNamesUnion) {
                StoreDefinition oldStoreDef = oldStoreDefinitionMap.get(storeName);
                StoreDefinition newStoreDef = newStoreDefinitionMap.get(storeName);
                if(oldStoreDef == null && newStoreDef != null || oldStoreDef != null
                   && newStoreDef == null || oldStoreDef != null && newStoreDef != null
                   && !oldStoreDef.equals(newStoreDef)) {
                    storesChanged.add(storeName);
                }
            }
            System.out.println("Updating metadata version for the following stores: "
                               + storesChanged);
            try {
                adminClient.metadataMgmtOps.updateMetadataversion(adminClient.getAdminClientCluster()
                                                                             .getNodeIds(),
                                                                  storesChanged);
            } catch(Exception e) {
                System.err.println("Error while updating metadata version for the specified store.");
            }
        }
1194226
@Override
    @Transactional
    public Snapshot updateHistory(Snapshot snapshot, String history) {
        snapshot = this.snapshotRepo.getOne(snapshot.getId());
        SnapshotHistory newHistory = new SnapshotHistory();
        newHistory.setHistory(history);
        newHistory.setSnapshot(snapshot);
        snapshot.getSnapshotHistory().add(newHistory);
        return this.snapshotRepo.save(snapshot);
    }
1156105
def snapshot_identifier(prefix, db_identifier):
    
    now = datetime.now()
    return '%s-%s-%s' % (prefix, db_identifier, now.strftime('%Y-%m-%d-%H-%M'))
1022577
private void upgradeDatabase(KelpUpgrade upgradeKelp)
    throws IOException
  {
    Collections.sort(_tableList, 
                     (x,y)->x.row().name().compareTo(y.row().name()));
    
    for (TableEntry10 table : _tableList) {
      TableUpgrade upgradeTable = upgradeKelp.table(table.key(), table.row());
      
      upgradeTable(table, upgradeTable);
    }
  }
845838
private boolean addBrandNewObject(DBObject dbObj) {
        if (Utils.isEmpty(dbObj.getObjectID())) {
            dbObj.setObjectID(Utils.base64FromBinary(IDGenerator.nextID()));
        }
        checkForNewShard(dbObj);
        for (String fieldName : dbObj.getUpdatedFieldNames()) {
            FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName);
            fieldUpdater.addValuesForField();
        }
        return true;
    }
179340
public static Response getBatchUpdateResponse(App app, Map<String, ParaObject> oldObjects,
			List<Map<String, Object>> newProperties) {
		try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
				RestUtils.class, "batch", "update")) {
			if (app != null && oldObjects != null && newProperties != null) {
				LinkedList<ParaObject> updatedObjects = new LinkedList<>();
				boolean hasPositiveVersions = false;
				for (Map<String, Object> newProps : newProperties) {
					if (newProps != null && newProps.containsKey(Config._ID)) {
						ParaObject oldObject = oldObjects.get((String) newProps.get(Config._ID));
						// updating apps in batch is not allowed
						if (oldObject != null && checkImplicitAppPermissions(app, oldObject)) {
							ParaObject updatedObject = ParaObjectUtils.setAnnotatedFields(oldObject, newProps, Locked.class);
							if (isValidObject(app, updatedObject) && checkIfUserCanModifyObject(app, updatedObject)) {
								updatedObject.setAppid(app.getAppIdentifier());
								updatedObjects.add(updatedObject);
								if (updatedObject.getVersion() != null && updatedObject.getVersion() > 0) {
									hasPositiveVersions = true;
								}
							}
						}
					}
				}
				Para.getDAO().updateAll(app.getAppIdentifier(), updatedObjects);
				// check if any or all updates failed due to optimistic locking
				return handleFailedUpdates(hasPositiveVersions, updatedObjects);
			} else {
				return getStatusResponse(Response.Status.BAD_REQUEST);
			}
		}
	}
815967
@Override
	public void update(
			final Serializable id,
			final Object[] fields,
			final int[] dirtyFields,
			final boolean hasDirtyCollection,
			final Object[] oldFields,
			final Object oldVersion,
			final Object object,
			final Object rowId,
			final SharedSessionContractImplementor session) throws HibernateException {

		//note: dirtyFields==null means we had no snapshot, and we couldn't get one using select-before-update
		//	  oldFields==null just means we had no snapshot to begin with (we might have used select-before-update to get the dirtyFields)

		//TODO support "multi table" entities
		final boolean[] tableUpdateNeeded = getTableUpdateNeeded( dirtyFields, hasDirtyCollection );
		final int span = getTableSpan();

		final boolean[] propsToUpdate;
		EntityEntry entry = session.getPersistenceContext().getEntry( object );

		// Ensure that an immutable or non-modifiable entity is not being updated unless it is
		// in the process of being deleted.
		if ( entry == null && ! isMutable() ) {
			throw new IllegalStateException( "Updating immutable entity that is not in session yet!" );
		}
		//we always use a dynamicUpdate model for Infinispan
		if ( (
				//getEntityMetamodel().isDynamicUpdate() &&
				dirtyFields != null ) ) {

			propsToUpdate = getPropertiesToUpdate( dirtyFields, hasDirtyCollection );
			// don't need to check laziness (dirty checking algorithm handles that)
		}
		else if ( ! isModifiableEntity( entry ) ) {
			//TODO does that apply to OGM?
			// We need to generate UPDATE SQL when a non-modifiable entity (e.g., read-only or immutable)
			// needs:
			// - to have references to transient entities set to null before being deleted
			// - to have version incremented do to a "dirty" association
			// If dirtyFields == null, then that means that there are no dirty properties to
			// to be updated; an empty array for the dirty fields needs to be passed to
			// getPropertiesToUpdate() instead of null.
			propsToUpdate = getPropertiesToUpdate(
					( dirtyFields == null ? ArrayHelper.EMPTY_INT_ARRAY : dirtyFields ),
					hasDirtyCollection
			);
			// don't need to check laziness (dirty checking algorithm handles that)
		}
		else {
			// For the case of dynamic-update="false", or no snapshot, we update all properties
			//TODO handle lazy
			propsToUpdate = getPropertyUpdateability( object );
		}

		final SessionFactoryImplementor factory = getFactory();
		if ( log.isTraceEnabled() ) {
			log.trace( "Updating entity: " + MessageHelper.infoString( this, id, factory ) );
			if ( isVersioned() ) {
				log.trace( "Existing version: " + oldVersion + " -> New version: " + fields[getVersionProperty()] );
			}
		}


		for ( int j = 0; j < span; j++ ) {
			// Now update only the tables with dirty properties (and the table with the version number)
			if ( tableUpdateNeeded[j] ) {
				final EntityKey key = EntityKeyBuilder.fromPersister( this, id, session );

				final boolean useVersion = j == 0 && isVersioned();

				if ( usesNonAtomicOptimisticLocking ) {
					final Tuple tupleInDatastore = getFreshTuple( key, session );
					final EntityMetamodel entityMetamodel = getEntityMetamodel();

					// Write any appropriate versioning conditional parameters
					if ( useVersion && entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.VERSION ) {
						if ( checkVersion( propsToUpdate ) ) {
							checkVersionAndRaiseSOSE( id, oldVersion, session, tupleInDatastore );
						}
					}
					else if ( isAllOrDirtyOptLocking() && oldFields != null ) {
						boolean[] versionability = getPropertyVersionability(); //TODO: is this really necessary????
						boolean[] includeOldField = entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.ALL
								? getPropertyUpdateability()
										: propsToUpdate;

						//TODO do a diff on the properties value from resultset and the dirty value
						GridType[] types = gridPropertyTypes;

						for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
							boolean include = includeOldField[i] &&
									isPropertyOfTable( i, j ) &&
									versionability[i]; //TODO: is this really necessary????
							if ( include ) {
								final GridType type = types[i];
								//FIXME what do do with settable?
								boolean[] settable = type.toColumnNullness( oldFields[i], factory );
								final Object snapshotValue = type.nullSafeGet(
										tupleInDatastore, getPropertyColumnNames( i ), session, object
										);

								if ( !type.isEqual( oldFields[i], snapshotValue, factory ) ) {
									raiseStaleObjectStateException( id );
								}
							}
						}
					}
				}

				TuplePointer tuplePointer = getSharedTuplePointer( key, object, session );
				Tuple resultset = tuplePointer.getTuple();
				resultset = createNewResultSetIfNull( key, resultset, id, session );
				resultset.setSnapshotType( SnapshotType.UPDATE );
				saveSharedTuple( object, resultset, session );

				if ( mightManageInverseAssociations ) {
					removeFromInverseAssociations( resultset, j, id, session );
				}
				dehydrate( resultset, fields, propsToUpdate, j, id, session );

				// TODO OGM-616 Also use this facet for "all columns" optimistic locking strategy
				if ( isVersioned() && optimisticLockingAwareGridDialect != null ) {
					Tuple oldVersionTuple = new Tuple();
					oldVersionTuple.put( getVersionColumnName(), oldVersion );

					boolean success = optimisticLockingAwareGridDialect.updateTupleWithOptimisticLock( key, oldVersionTuple, resultset, getTupleContext( session ) );

					// If there is an error handler registered, pass the applied/failed operation to it as needed
					if ( success ) {
						if ( invocationCollectingGridDialect != null ) {
							invocationCollectingGridDialect.onUpdateTupleWithOptimisticLockSuccess( key, oldVersionTuple, resultset );
						}
					}
					else {
						if ( invocationCollectingGridDialect != null ) {
							try {
								raiseStaleObjectStateException( id );
							}
							catch (Exception e) {
								invocationCollectingGridDialect.onUpdateTupleWithOptimisticLockFailure( key, oldVersionTuple, resultset, e );
							}
						}
						else {
							raiseStaleObjectStateException( id );
						}
					}
				}
				else {
					insertOrUpdateTuple( key, tuplePointer, hasUpdateGeneratedProperties(), session );
				}

				if ( mightManageInverseAssociations ) {
					addToInverseAssociations( resultset, j, id, session );
				}
			}
		}
	}
484339
@GET
    @Path("{dbName}/{revision}")
    public Response info(@PathParam("dbName") String dbName, @PathParam("revision") String revision) {
        Flyway flyway = locator.getService(Flyway.class, dbName);
        if (flyway == null)
            throw new NotFoundException();
        Object entity = null;
        switch (revision) {
            case "current":
                entity = flyway.info().current();
                break;
            case "pending":
                entity = flyway.info().pending();
                break;
            case "applied":
                entity = flyway.info().applied();
                break;
            case "first": {
                MigrationInfo[] migrationInfos = flyway.info().all();
                if (migrationInfos.length == 0)
                    throw new NotFoundException();
                entity = migrationInfos[0];
                break;
            }
            case "resolved":
                entity = resolved(flyway.info().all());
                break;
            case "failed":
                entity = failed(flyway.info().all());
                break;
            case "future":
                entity = future(flyway.info().all());
                break;
            case "latest": {
                MigrationInfo[] migrationInfos = flyway.info().all();
                if (migrationInfos.length == 0)
                    throw new NotFoundException();
                entity = migrationInfos[migrationInfos.length - 1];
                break;
            }
            default:
                for (MigrationInfo info : flyway.info().all()) {
                    if (revision.equalsIgnoreCase(info.getVersion().getVersion())) {
                        entity = info;
                        break;
                    }
                }
        }
        if (entity == null)
            throw new NotFoundException();
        return Response.ok(entity).build();
    }
132817
public void setDBClusterSnapshots(java.util.Collection<DBClusterSnapshot> dBClusterSnapshots) {
        if (dBClusterSnapshots == null) {
            this.dBClusterSnapshots = null;
            return;
        }

        this.dBClusterSnapshots = new java.util.ArrayList<DBClusterSnapshot>(dBClusterSnapshots);
    }
451361
function IDBDatabase(db, name, version, storeProperties){
        this.__db = db;
        this.__closed = false;
        this.version = version;
        this.name = name;
        this.onabort = this.onerror = this.onversionchange = null;

        this.__objectStores = {};
        this.objectStoreNames = new idbModules.util.StringList();
        for (var i = 0; i < storeProperties.rows.length; i++) {
            var store = new idbModules.IDBObjectStore(storeProperties.rows.item(i));
            this.__objectStores[store.name] = store;
            this.objectStoreNames.push(store.name);
        }
    }
388928
protected Object handleColumnValue(final Object oldValue, final Database database) {
      final Object newValue = WktConversionUtils.handleColumnValue(oldValue, database, this);
      return newValue;
   }
78054
public Snapshot getCurrentSnapshot() {
    Map.Entry<Long, Snapshot> entry = snapshots.lastEntry();
    return entry != null ? entry.getValue() : null;
  }