Skip to content

Commit 00cb3be

Browse files
authored
docs(Datastore): add MIGRATING.md (#8651)
1 parent 4d40b42 commit 00cb3be

2 files changed

Lines changed: 153 additions & 0 deletions

File tree

Datastore/MIGRATING.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Migrating Google Datastore from V1 to V2
2+
3+
## How to upgrade
4+
5+
Update your `google/cloud-datastore` dependency to `^2.0`:
6+
7+
```
8+
{
9+
"require": {
10+
"google/cloud-datastore": "^2.0"
11+
}
12+
}
13+
```
14+
15+
## Breaking Changes
16+
17+
### EntityInterface changes
18+
19+
Types have been added to the methods in [`EntityInterface`](src/EntityInterface.php). This means that
20+
any classes implementing this interface will need to be updated to match the new method signatures:
21+
22+
```diff
23+
class Business implements EntityInterface
24+
{
25+
use EntityTrait;
26+
27+
- public static function mappings()
28+
+ public static function mappings(): array
29+
{
30+
return [
31+
'parent' => Business::class
32+
];
33+
}
34+
}
35+
```
36+
37+
### Client Options changes
38+
39+
The following [`ClientOptions`][ClientOptions] have been reorganized. This was
40+
done to ensure client options are consistent across all Google Cloud clients.
41+
42+
- `authCache` -> Moved to `credentialsConfig.authCache`
43+
- `authCacheOptions` -> Moved to `credentialsConfig.authCacheOptions`
44+
- `credentialsFetcher` -> Moved to `credentials`
45+
- `keyFile` -> Moved to `credentials`
46+
- `keyFilePath` -> Moved to `credentials`
47+
- `requestTimeout` -> Removed from client options and moved to a call option `timeoutMillis`
48+
- `scopes` -> Moved to `credentialsConfig.scopes`
49+
- `defaultScopes` -> Moved to `credentialsConfig.defaultScopes`
50+
- `quotaProject` -> Moved to `credentialsConfig.quotaProject`
51+
- `httpHandler` -> Moved to `transportConfig.rest.httpHandler`
52+
- `authHttpHandler` -> Moved to `credentialsConfig.authHttpHandler`
53+
- `asyncHttpHandler` -> Removed in favor of a single httpHandler option.
54+
- `restOptions` -> Moved to `transportConfig.rest`
55+
- `grpcOptions` -> Moved to `transportConfig.grpc`
56+
- `accessToken` -> Removed - This option is no longer supported. Use the `$credentialsFetcher` option instead.
57+
- `shouldSignRequest` -> Removed - obsolete
58+
- `preferNumericProjectId` -> Removed - obsolete
59+
60+
### Retry Options changes
61+
62+
The retry options have been moved to use [`RetrySettings`][RetrySettings] in Client Options and in
63+
call options.
64+
65+
- `retries` -> Renamed to `retrySettings.maxRetries`
66+
- `restRetryFunction` -> Renamed to `retrySettings.retryFunction`
67+
- `grpcRetryFunction` -> Renamed to `retrySettings.retryFunction`
68+
- `delayFunc`/`calcDelayFunction` -> Removed in favor of the properties
69+
`retrySettings.initialRetryDelayMillis`, `retrySettings.retryDelayMultiplier` and
70+
`retrySettings.maxRetryDelayMillis`.
71+
72+
[RetrySettings]: https://cloud.google.com/php/docs/reference/gax/latest/RetrySettings
73+
[ClientOptions]: https://cloud.google.com/php/docs/reference/gax/latest/Options.ClientOptions
74+
75+
## Internal changes
76+
77+
We expect these changes to not break existing code, as they have been done in
78+
classes marked `@internal` or as part of refactoring, but to be safe, these
79+
changes have been released in a major version.
80+
81+
### Types for properties, parameters, and return types.
82+
83+
Types have been added for all properties, parameters and return types. This means that any classes
84+
implementing interfaces in this library (specifically, `EntityInterface` as mentioned above),
85+
will need to be updated to match the new method signatures. Typing constraints may have other effects
86+
where the incorrect types had been previously applied.
87+
88+
### Options array validation
89+
90+
Previously, if unrecognized array keys were passed into methods, these additional arguments would
91+
be ignored. Now, a `LogicException` will be thrown in the `OptionsValidator` class with the message
92+
"Unexpected option(s) provided: [OPTION-NAME]". If you see this exception, and you believe it to be
93+
an error, please file an issue in the [google-cloud-php repo][google-cloud-php-issues] and let us
94+
know.
95+
96+
[google-cloud-php-issues]: https://github.com/googleapis/google-cloud-php/issues
97+
98+
### Connection classes are not used anymore.
99+
100+
The following classes are removed, and have been replaced with the generated
101+
GAPIC client `Google\Cloud\Datastore\V1\Client\DatastoreClient`:
102+
103+
- `Google\Cloud\Datastore\Connection\ConnectionInterface` is removed
104+
- `Google\Cloud\Datastore\Connection\Rest` is removed
105+
- `Google\Cloud\Datastore\Connection\Grpc` is removed
106+
107+
Additionally, the previously generated GAPIC client
108+
(`Google\Cloud\Datastore\V1\DatastoreClient`, which has a similar name to
109+
`Google\Cloud\Datastore\V1\Client\DatastoreClient`, but without the `Client`
110+
namespace) has been removed. For more information, see
111+
[Migrating to V2][migrating-to-v2].
112+
113+
[migrating-to-v2]: https://cloud.google.com/php/docs/reference/help/migrating
114+
115+
### Constants in `Query\Query` have been changed from string to int
116+
117+
These constants are used internally, but if they are being used in any code, they will need to be
118+
updated:
119+
120+
- `Google\Cloud\Datastore\Query\Query::OP_DEFAULT` changed from `'EQUAL'` to `5`
121+
- `Google\Cloud\Datastore\Query\Query::OP_LESS_THAN` changed from `'LESS_THAN'` to `1`
122+
- `Google\Cloud\Datastore\Query\Query::OP_LESS_THAN_OR_EQUAL` changed from `'LESS_THAN_OR_EQUAL'` to `2`
123+
- `Google\Cloud\Datastore\Query\Query::OP_GREATER_THAN` changed from `'GREATER_THAN'` to `3`
124+
- `Google\Cloud\Datastore\Query\Query::OP_GREATER_THAN_OR_EQUAL` changed from `'GREATER_THAN_OR_EQUAL'` to `4`
125+
- `Google\Cloud\Datastore\Query\Query::OP_EQUALS` changed from `'EQUAL'` to `5`
126+
- `Google\Cloud\Datastore\Query\Query::OP_NOT_EQUALS` changed from `'NOT_EQUAL'` to `9`
127+
- `Google\Cloud\Datastore\Query\Query::OP_IN` changed from `'IN'` to `6`
128+
- `Google\Cloud\Datastore\Query\Query::OP_NOT_IN` changed from `'NOT_IN'` to `13`
129+
- `Google\Cloud\Datastore\Query\Query::OP_HAS_ANCESTOR` changed from `'HAS_ANCESTOR'` to `11`
130+
- `Google\Cloud\Datastore\Query\Query::ORDER_DEFAULT` changed from `'ASCENDING'` to `1`
131+
- `Google\Cloud\Datastore\Query\Query::ORDER_DESCENDING` changed from `'DESCENDING'` to `2`
132+
- `Google\Cloud\Datastore\Query\Query::ORDER_ASCENDING` changed from `'ASCENDING'` to `1`
133+
134+
### Protobuf backwards compatibility files have been removed
135+
136+
These class aliases have been deprecated for a very long time, and are finally being removed. Update
137+
to the namespaced version (replacing `_` with `\`) to upgrade.
138+
139+
- `Google\Cloud\Datastore\V1\PropertyFilter_Operator` has been removed
140+
- `Google\Cloud\Datastore\V1\EntityResult_ResultType` has been removed
141+
- `Google\Cloud\Datastore\V1\CommitRequest_Mode` has been removed
142+
- `Google\Cloud\Datastore\V1\CompositeFilter_Operator` has been removed
143+
- `Google\Cloud\Datastore\V1\TransactionOptions_ReadWrite` has been removed
144+
- `Google\Cloud\Datastore\V1\QueryResultBatch_MoreResultsType` has been removed
145+
- `Google\Cloud\Datastore\V1\TransactionOptions_ReadOnly` has been removed
146+
- `Google\Cloud\Datastore\V1\PropertyOrder_Direction` has been removed
147+
- `Google\Cloud\Datastore\V1\AggregationQuery_Aggregation` has been removed
148+
- `Google\Cloud\Datastore\V1\ReadOptions_ReadConsistency` has been removed
149+
- `Google\Cloud\Datastore\V1\Key_PathElement` has been removed
150+
- `Google\Cloud\Datastore\V1\AggregationQuery_Aggregation_Count` has been removed
151+

Datastore/src/Operation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
* Examples are omitted for brevity. Detailed usage examples can be found in
5959
* {@see \Google\Cloud\Datastore\DatastoreClient} and
6060
* {@see \Google\Cloud\Datastore\Transaction}.
61+
*
62+
* @internal
6163
*/
6264
class Operation
6365
{

0 commit comments

Comments
 (0)