updateGlobalSecondaryIndex
updateGlobalSecondaryIndex
is a Change Type in the Liquibase DynamoDB Pro extension that updates an existing global secondary index on a table. For more information, see Using Global Secondary Indexes in DynamoDB.
Uses
A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key. A global secondary index is an index with a partition key and sort key that can be different from those on the table. It is different from a local secondary index, which is an index with the same partition key as the table, but a different sort key. For more information, see Core components of Amazon DynamoDB.
Run updateGlobalSecondaryIndex
To run this Change Type, follow these steps:
- Add the Change Type to your changeset, as shown in the examples on this page.
- Specify any required attributes. Use the table on this page to see which ones your database requires.
- Deploy your changeset by running the
update
command:
liquibase update
Now, Liquibase deploys your change on your DynamoDB database. By default, read operations on DynamoDB are eventually consistent. When you look at your database immediately after running liquibase update
, DynamoDB may display the status of an object as CREATING
, UPDATING
, or DELETING
. When it finishes, it displays the status as ACTIVE
.
Note: If your deployment fails because the DynamoDB waiter times out or reaches a retry limit, you can modify the waiter settings using Liquibase Parameters for Amazon DynamoDB Pro.
Available attributes
For more information, see DynamoDB API: UpdateTable and DynamoDB API UpdateGlobalSecondaryIndexAction.
Tip: You must specify all top-level attributes marked as required. If you specify an optional attribute, you must also specify any nested attributes that it requires.
Name | Type | Description | Requirement |
---|---|---|---|
tableName
|
String |
Name of the table for which to update the index |
Required |
indexName
|
String |
Name of the index to create |
Required |
provisionedThroughput
Optional.
- If you set
billingMode
toPROVISIONED
, or if you do not explicitly setbillingMode
, thenprovisionedThroughput
is required. - If you set
billingMode
toPAY_PER_REQUEST
, you cannot specifyprovisionedThroughput
.
Specifies the provisioned throughput settings for the table. You can modify these settings using the updateDynamoTable
and updateTableProvisionedThroughput
Change Types.
Note: If you originally set billingMode
to PROVISIONED
and want to change it to PAY_PER_REQUEST
, you must do this with updateDynamoTable
. You cannot use updateTableProvisionedThroughput
because it only accepts the PROVISIONED
billing mode.
provisionedThroughput
has the following nested attributes:
readCapacityUnits
(required): the maximum number of reads per second before DynamoDB returns aThrottlingException
. Minimum valid value:1
.writeCapacityUnits
(required): the maximum number of writes per second before DynamoDB returns aThrottlingException
. Minimum valid value:1
.
If you set billingMode
to PAY_PER_REQUEST
, Liquibase sets the values of readCapacityUnits
and writeCapacityUnits
to 0
.
For more information, see Read/write capacity mode and Managing settings on DynamoDB provisioned capacity tables.
Note: When you specify provisionedThroughput
at the top level, it applies to the table. When you specify provisionedThroughput
within globalSecondaryIndex
, it applies to the index.
Examples
databaseChangeLog:
- changeSet:
id: 2
author: your.name
changes:
- updateGlobalSecondaryIndex:
tableName: updateGlobalIndexTestYaml
indexName: globalIndexYaml
provisionedThroughput:
readCapacityUnits: 15
writeCapacityUnits: 15
rollback:
- updateGlobalSecondaryIndex:
tableName: updateGlobalIndexTestYaml
indexName: globalIndexYaml
provisionedThroughput:
readCapacityUnits: 10
writeCapacityUnits: 10
{
"databaseChangeLog": [
{
"changeSet": {
"id": "2",
"author": "your.name",
"changes": [
{
"updateGlobalSecondaryIndex": {
"tableName": "updateGlobalIndexTestJson",
"indexName": "globalIndexJson",
"provisionedThroughput": {
"readCapacityUnits": 15,
"writeCapacityUnits": 15
}
}
}
],
"rollback": [
{
"updateGlobalSecondaryIndex": {
"tableName": "updateGlobalIndexTestJson",
"indexName": "globalIndexJson",
"provisionedThroughput": {
"readCapacityUnits": 10,
"writeCapacityUnits": 10
}
}
}
]
}
}
]
}
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dynamodb="http://www.liquibase.org/xml/ns/pro-dynamodb"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/pro-dynamodb
http://www.liquibase.org/xml/ns/pro-dynamodb/liquibase-pro-dynamodb-latest.xsd">
<changeSet id="2" author="your.name">
<dynamodb-pro:updateGlobalSecondaryIndex tableName="updateGlobalIndexTest" indexName="globalIndex">
<dynamodb-pro:provisionedThroughput readCapacityUnits="15" writeCapacityUnits="15"/>
</dynamodb-pro:updateGlobalSecondaryIndex>
<rollback>
<dynamodb-pro:updateGlobalSecondaryIndex tableName="updateGlobalIndexTest" indexName="globalIndex">
<dynamodb-pro:provisionedThroughput readCapacityUnits="10" writeCapacityUnits="10"/>
</dynamodb-pro:updateGlobalSecondaryIndex>
</rollback>
</changeSet>
</databaseChangeLog>
Database support
This Change Type is only supported for Amazon DynamoDB. It does not support auto rollback.