Migrating Google Datastore from V1 to V2
How to upgrade
Update yourgoogle/cloud-datastore dependency to^2.0:
{ "require": { "google/cloud-datastore": "^2.0" }}Breaking Changes
EntityInterface changes
Types have been added to the methods inEntityInterface. This means thatany classes implementing this interface will need to be updated to match the new method signatures:
class Business implements EntityInterface { use EntityTrait;- public static function mappings()+ public static function mappings(): array { return [ 'parent' => Business::class ]; } }Client Options changes
The followingClientOptions have been reorganized. This wasdone to ensure client options are consistent across all Google Cloud clients.
authCache-> Moved tocredentialsConfig.authCacheauthCacheOptions-> Moved tocredentialsConfig.authCacheOptionscredentialsFetcher-> Moved tocredentialskeyFile-> Moved tocredentialskeyFilePath-> Moved tocredentialsrequestTimeout-> Removed from client options and moved to a call optiontimeoutMillisscopes-> Moved tocredentialsConfig.scopesdefaultScopes-> Moved tocredentialsConfig.defaultScopesquotaProject-> Moved tocredentialsConfig.quotaProjecthttpHandler-> Moved totransportConfig.rest.httpHandlerauthHttpHandler-> Moved tocredentialsConfig.authHttpHandlerasyncHttpHandler-> Removed in favor of a single httpHandler option.restOptions-> Moved totransportConfig.restgrpcOptions-> Moved totransportConfig.grpcaccessToken-> Removed - This option is no longer supported. Use the$credentialsFetcheroption instead.shouldSignRequest-> Removed - obsoletepreferNumericProjectId-> Removed - obsolete
Retry Options changes
The retry options have been moved to useRetrySettings in Client Options and incall options.
retries-> Renamed toretrySettings.maxRetriesrestRetryFunction-> Renamed toretrySettings.retryFunctiongrpcRetryFunction-> Renamed toretrySettings.retryFunctiondelayFunc/calcDelayFunction-> Removed in favor of the propertiesretrySettings.initialRetryDelayMillis,retrySettings.retryDelayMultiplierandretrySettings.maxRetryDelayMillis.
Internal changes
We expect these changes to not break existing code, as they have been done inclasses marked@internal or as part of refactoring, but to be safe, thesechanges have been released in a major version.
Types for properties, parameters, and return types.
Types have been added for all properties, parameters and return types. This means that any classesimplementing interfaces in this library (specifically,EntityInterface as mentioned above),will need to be updated to match the new method signatures. Typing constraints may have other effectswhere the incorrect types had been previously applied.
Options array validation
Previously, if unrecognized array keys were passed into methods, these additional arguments wouldbe ignored. Now, aLogicException will be thrown in theOptionsValidator class with the message"Unexpected option(s) provided: [OPTION-NAME]". If you see this exception, and you believe it to bean error, please file an issue in thegoogle-cloud-php repo and let usknow.
Connection classes are not used anymore.
The following classes are removed, and have been replaced with the generatedGAPIC clientGoogle\Cloud\Datastore\V1\Client\DatastoreClient:
Google\Cloud\Datastore\Connection\ConnectionInterfaceis removedGoogle\Cloud\Datastore\Connection\Restis removedGoogle\Cloud\Datastore\Connection\Grpcis removed
Additionally, the previously generated GAPIC client(Google\Cloud\Datastore\V1\DatastoreClient, which has a similar name toGoogle\Cloud\Datastore\V1\Client\DatastoreClient, but without theClientnamespace) has been removed. For more information, seeMigrating to V2.
Constants inQuery\Query have been changed from string to int
These constants are used internally, but if they are being used in any code, they will need to beupdated:
Google\Cloud\Datastore\Query\Query::OP_DEFAULTchanged from'EQUAL'to5Google\Cloud\Datastore\Query\Query::OP_LESS_THANchanged from'LESS_THAN'to1Google\Cloud\Datastore\Query\Query::OP_LESS_THAN_OR_EQUALchanged from'LESS_THAN_OR_EQUAL'to2Google\Cloud\Datastore\Query\Query::OP_GREATER_THANchanged from'GREATER_THAN'to3Google\Cloud\Datastore\Query\Query::OP_GREATER_THAN_OR_EQUALchanged from'GREATER_THAN_OR_EQUAL'to4Google\Cloud\Datastore\Query\Query::OP_EQUALSchanged from'EQUAL'to5Google\Cloud\Datastore\Query\Query::OP_NOT_EQUALSchanged from'NOT_EQUAL'to9Google\Cloud\Datastore\Query\Query::OP_INchanged from'IN'to6Google\Cloud\Datastore\Query\Query::OP_NOT_INchanged from'NOT_IN'to13Google\Cloud\Datastore\Query\Query::OP_HAS_ANCESTORchanged from'HAS_ANCESTOR'to11Google\Cloud\Datastore\Query\Query::ORDER_DEFAULTchanged from'ASCENDING'to1Google\Cloud\Datastore\Query\Query::ORDER_DESCENDINGchanged from'DESCENDING'to2Google\Cloud\Datastore\Query\Query::ORDER_ASCENDINGchanged from'ASCENDING'to1
Protobuf backwards compatibility files have been removed
These class aliases have been deprecated for a very long time, and are finally being removed. Updateto the namespaced version (replacing_ with\) to upgrade.
Google\Cloud\Datastore\V1\PropertyFilter_Operatorhas been removedGoogle\Cloud\Datastore\V1\EntityResult_ResultTypehas been removedGoogle\Cloud\Datastore\V1\CommitRequest_Modehas been removedGoogle\Cloud\Datastore\V1\CompositeFilter_Operatorhas been removedGoogle\Cloud\Datastore\V1\TransactionOptions_ReadWritehas been removedGoogle\Cloud\Datastore\V1\QueryResultBatch_MoreResultsTypehas been removedGoogle\Cloud\Datastore\V1\TransactionOptions_ReadOnlyhas been removedGoogle\Cloud\Datastore\V1\PropertyOrder_Directionhas been removedGoogle\Cloud\Datastore\V1\AggregationQuery_Aggregationhas been removedGoogle\Cloud\Datastore\V1\ReadOptions_ReadConsistencyhas been removedGoogle\Cloud\Datastore\V1\Key_PathElementhas been removedGoogle\Cloud\Datastore\V1\AggregationQuery_Aggregation_Counthas been removed
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-01-24 UTC.