You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CLI flag for specifying default SKIP RANGE and START COUNTER WITH values for IDENTITY columns (#1236)
* Add default identity options to Conv struct for use when converting to IDENTITY auto gen columns
The actual setting of the default identity options from CLI will come in a later commit.
* Add target profile flags for setting the default skip range and start counter with values for IDENTITY columns
* Populate DefaultIdentityOptions in conv from values read in via target profile
* Update docs
* Ensure default identity options are used for postgres IDENTITY columns as well
* Update docs
* Add integration test for default identity options and fix issue with DDL generation
* Add comment describing expected format
Copy file name to clipboardExpand all lines: docs/cli/flags.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,3 +78,11 @@ Time Zone Database](https://www.iana.org/time-zones). If not specified, the defa
78
78
the Spanner database, and the database will therefore default to `America/Los_Angeles` (the default timezone for
79
79
Spanner databases). Note, the default timezone can only be set on an empty Spanner database without any tables; a
80
80
warning will be logged and this setting will be ignored if the database already includes tables.
81
+
82
+
***`defaultIdentitySkipRange`**: Optional flag. Specifies the default SKIP RANGE values to use for IDENTITY columns. Specified as `<min>-<max>`, where both `<min>` and `<max>` are positive integers and `<min>` must be less than `<max>`. For example, `defaultIdentitySkipRange=10-50`. For
83
+
instructions on setting SKIP RANGE values for individual columns, see
***`defaultIdentityStartCounterWith`**: Optional flag. Specifies the default START COUNTER WITH value to use for IDENTITY columns. This should be a positive integer. For example, `defaultIdentityStartCounterWith=1000`. For
87
+
instructions on setting the START COUNTER WITH value for individual columns, see
Users need to set the SKIP RANGE and/or START COUNTER WITH values to avoid duplicate key errors.
178
178
179
-
The SKIP RANGE and START COUNTER WITH values can be set most via both the web UI (recommended) and the CLI.
179
+
The SKIP RANGE and START COUNTER WITH values can be set via both the web UI (recommended) and the CLI.
180
180
181
181
The Column tab of the web UI exposes fields to set the SKIP RANGE and START COUNTER WITH values. For more details, see [here](../ui/schema-conv/spanner-draft.md).
182
182
183
-
To set the SKIP RANGE and/or START COUNTER WITH values via the CLI, the recommended steps are as follows:
183
+
To set the SKIP RANGE and/or START COUNTER WITH values via the CLI, there are two options: either specify default
184
+
values to be used by all IDENTITY columns, or specify values on a per-column basis. Both options can be used in
185
+
conjuction with one another.
186
+
187
+
To specify default SKIP RANGE and/or START COUNTER WITH values to be used by all columns, include the following flags
188
+
in the `targetProfile` parameter: `defaultIdentitySkipRange` and `defaultIdentityStartCounterWith`, for example:
Copy file name to clipboardExpand all lines: docs/data-types/postgres.md
+33-22Lines changed: 33 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,37 +66,46 @@ with type `INT64`.
66
66
67
67
Users need to set the SKIP RANGE and/or START COUNTER WITH values to avoid duplicate key errors.
68
68
69
-
The SKIP RANGE and START COUNTER WITH values can be set most via both the web UI (recommended) and the CLI.
69
+
The SKIP RANGE and START COUNTER WITH values can be set via both the web UI (recommended) and the CLI.
70
70
71
71
The Column tab of the web UI exposes fields to set the SKIP RANGE and START COUNTER WITH values. For more details, see [here](../ui/schema-conv/spanner-draft.md).
72
72
73
-
To set the SKIP RANGE and/or START COUNTER WITH values via the CLI, the recommended steps are as follows:
73
+
To set the SKIP RANGE and/or START COUNTER WITH values via the CLI, there are two options: either specify default
74
+
values to be used by all IDENTITY columns, or specify values on a per-column basis. Both options can be used in
75
+
conjuction with one another.
76
+
77
+
To specify default SKIP RANGE and/or START COUNTER WITH values to be used by all columns, include the following flags
78
+
in the `targetProfile` parameter: `defaultIdentitySkipRange` and `defaultIdentityStartCounterWith`, for example:
returnDefaultIdentityOptions{}, fmt.Errorf(fmt.Sprintf("Invalid value for defaultIdentitySkipRange: %s, expected <min>-<max> where both <min> and <max> are integers and <min> is less than <max>. %s", defaultSkipRangeStr, err))
194
+
}
195
+
defaultIdentityOptions.SkipRangeMin=skipRangeMin
196
+
defaultIdentityOptions.SkipRangeMax=skipRangeMax
197
+
}
198
+
ifdefaultStartCounterWith, ok:=params["defaultIdentityStartCounterWith"]; ok {
returnDefaultIdentityOptions{}, fmt.Errorf("Invalid value for defaultIdentityStartCounterWith: %s, expected a positive integer.", defaultStartCounterWith)
0 commit comments